I want to implement an 'robot' that could automatically fill forms.
Is there an solution when you can fill data on page for example,form1.html
and submit it, wait to next page and submit with data on form2.html
,and so on...
In the end it should also 'click' on a button to get a file that the form creates.
I want this 'robot' would use some confidential information, so it cant be done using client side
technologies.
I was thinking about PHP
- building it as a web site-web service, so you could transfer data to a web address, or a Web Service in .Net
.
If it's important,the site I want to fill automatically is runs with ASP.NET
.
I kind a new here...Can anyone give some examples or tutorials doing this thing. If exist some technologies that I didn't mention here to realize it I would be glad trying them also.
Forms work by posting data, so instead of making a robot that would type something into every field and click submit, you can just POST
the data to the server.
First grab the form fields names, and the action
of the form.
Then CURL:
//set POST variables
$url = 'http://domain.com/get-post.php';
$fields = array(
'lname' => urlencode($last_name),
'fname' => urlencode($first_name),
'title' => urlencode($title),
'company' => urlencode($institution),
'age' => urlencode($age),
'email' => urlencode($email),
'phone' => urlencode($phone)
);
//url-ify the data for the POST
foreach($fields as $key=>$value) { $fields_string .= $key.'='.$value.'&'; }
rtrim($fields_string, '&');
//open connection
$ch = curl_init();
//set the url, number of POST vars, POST data
curl_setopt($ch,CURLOPT_URL, $url);
curl_setopt($ch,CURLOPT_POST, count($fields));
curl_setopt($ch,CURLOPT_POSTFIELDS, $fields_string);
//execute post
$result = curl_exec($ch);
//close connection
curl_close($ch);
Snippet from this site.