I am trying to scrape a web page generated by ASP.NET using PHP language.
In localhost I got the info that I need (the book data), but when I try in server. I got the following error: Object Moved Here It can be checked here
Reading about the problem, I realize that scraping pages generated by ASP.net is difficult because you have to recover a VIEWSTATE and another kind of info. I try to get it, but I'm not sure if it is the cause of the problem or it can be another reason.
My code is:
$url = "http://www.panamericana.com.co/busqueda/el%20laberinto%20de%20los%20espiritus/0";
$ch = curl_init($url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, false);
$result = curl_exec($ch);
preg_match_all("/id=\"__VIEWSTATE\" value=\"(.*?)\"/", $result, $arr_viewstate);
$viewstate = urlencode($arr_viewstate[1][0]);
$options = array(
CURLOPT_RETURNTRANSFER => true,
CURLOPT_HEADER => true,
CURLOPT_FOLLOWLOCATION => false,
CURLOPT_ENCODING => "",
CURLOPT_USERAGENT => "spider",
CURLOPT_AUTOREFERER => true,
CURLOPT_CONNECTTIMEOUT => 120,
CURLOPT_MAXREDIRS => 10,
CURLOPT_POST => true,
CURLOPT_POSTFIELDS => '__VIEWSTATE=' . $viewstate);
$ch = curl_init($url);
curl_setopt_array($ch, $options);
$result = curl_exec($ch);
echo $result;