 |
 |
 |
 |
| Programming & Packaging A place to discuss programming and packaging. |

3rd March 2011, 02:21 AM
|
|
Registered User
|
|
Join Date: Dec 2010
Posts: 174

|
|
Auto form completion.
I am working on a database project where I start with a .csv downloaded from the internet. In order to download the .csv one must fill out three web forms one after another before a download link is finally presented. I have been charged with automating the process of downloading this file. Is there a way that this can be done? I am looking for some insight.
Thanks!
|

3rd March 2011, 11:01 AM
|
 |
"Fixed" by (vague) request
|
|
Join Date: Oct 2005
Location: GMT+ 1
Posts: 2,950

|
|
|
Re: Auto form completion.
Sometime ago we were using Selenium to automate testing of web apps. It's useful to load large amounts of data in web pages
|

5th April 2011, 05:15 AM
|
 |
Banned
|
|
Join Date: Jul 2006
Location: Transgression
Age: 33
Posts: 1,183

|
|
|
Re: Auto form completion.
Why don't you just WRITE something to do that? Eg, a site spammer/form poster. It's relatively quick and easy, in php.
|

5th April 2011, 05:50 AM
|
|
Registered User
|
|
Join Date: Dec 2010
Posts: 174

|
|
|
Re: Auto form completion.
If I had an example I might be able to do that. Do you know where I can find some existing code?
|

5th April 2011, 05:56 AM
|
 |
Banned
|
|
Join Date: Jul 2006
Location: Transgression
Age: 33
Posts: 1,183

|
|
|
Re: Auto form completion.
Sure, i do  :
Code:
<?
$txt = '&subject=This+is+my+subject&message=I+wanted+to+take+a+moment+to+talk+to+you+about+viagra&action=post&submit=1&button.x=50&button.y=6';
$cookie = 'username=xxx; session=yyy';
$url = 'http://www.xxx.com/messages.php';
$i = 1;
while ($i < 804){
$url = 'http://www.xxx.com/members.php?page='.$i;
$html = file_get_contents($url);
preg_match_all('/\/members\/profile\.php\?name\=([a-zA-Z0-9\-\_]+)/',$html,$matches);
$i++;
$matches = $matches[1];
$matches = array_unique($matches);
$f = fopen('/home/vector/Desktop/users.txt', 'a');
foreach((array)$matches as $match){
fwrite($f, $match."\n");
}
fclose($f);
echo count($matches),"\n";
}
$matches = explode("\n",file_get_contents('/home/vector/Desktop/users.txt'));
//echo $matches;
//print_r($matches);
$i = 0;
foreach((array)$matches as $match){
echo "\n\n\nSending to user {$i} ({$match})\n\n\n";
$ch = curl_init();
curl_setopt($ch, CURLOPT_PROXY, '127.0.0.1:9050');
curl_setopt($ch, CURLOPT_PROXYTYPE, CURLPROXY_SOCKS5);
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_VERBOSE, 1);
curl_setopt($ch, CURLOPT_COOKIE, $cookie);
curl_setopt($ch, CURLOPT_USERAGENT, 'Windows Internet Explorer 9.5.43');
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, 'name='.$match.$txt);
$r = curl_exec($ch);
//echo $r;
exec("sleep 1");
$i++;
}
Don't ask, don't tell
Last edited by Vector; 5th April 2011 at 05:59 AM.
|
| Thread Tools |
Search this Thread |
|
|
|
| Display Modes |
Linear Mode
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
Current GMT-time: 07:36 (Tuesday, 18-06-2013)
|
|
 |
 |
 |
 |
|
|