Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Creating a 'robot' to fill form with some pages in

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.

like image 764
Dima Avatar asked Jun 24 '13 07:06

Dima


People also ask

How do I create an auto filler form?

Click on the Address Field, which will open on the right side of the screen its own settings. Once on it, you'll scroll down until Advanced options. There you'll see Google Autocomplete. Switch it On.


2 Answers

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.

like image 152
Adam Avatar answered Sep 21 '22 14:09

Adam


Use Selenium.

"Selenium automates browsers. That's it. What you do with that power is entirely up to you. Primarily it is for automating web applications for testing purposes, but is certainly not limited to just that. Boring web-based administration tasks can (and should!) also be automated as well."

See examples here.

enter image description here

like image 34
Voice Avatar answered Sep 19 '22 14:09

Voice