I am trying to create a bot to automatically scrape some data from a website. I am trying to use the Snoopy PHP class for this.
The problem I am having is that I cannot submit the login form page. I am passing the username and password in the field, but "nothing happens" - I don't get logged in and an error is not returned (such as invalid password).
I have tried using cURL directly (without the Snoopy class), but that doesn't help.
I feel that I am not passing the form variables correctly. I would appreciate it if someone could point me in the right direction.
The code I am using is:
$snoopy = new Snoopy;
$submit_url = "";
$submit_vars['ctl00$cphMainContent$ctl00$UsernameTextBox'] = "";
$submit_vars['ctl00$cphMainContent$ctl00$PasswordTextBox'] = "";
if($snoopy->submit($submit_url,$submit_vars)) {
while(list($key,$val) = each($snoopy->headers)) {
echo $key.": ".$val."<br>\n";
}
echo "<p>\n";
echo "<PRE>".htmlspecialchars($snoopy->results)."</PRE>\n";
} else {
echo "error fetching document: ".$snoopy->error."\n";
}