Jump to content

Page using Curl

- - - - -

  • Please log in to reply
No replies to this topic

#1
storyera

storyera

    Newbie

  • Members
  • Pip
  • 1 posts
hey! i am trying to get a certain page using curl... but when evr i try and access the page i am redirected to d homepage...

<?

set_time_limit(0);

//set curl

$ch = curl_init();

$ckfile = "tmp/cookie.txt";

curl_setopt ($ch, CURLOPT_COOKIEJAR, $ckfile);

curl_setopt ($ch, CURLOPT_COOKIEFILE, $ckfile);

curl_setopt($ch, CURLOPT_URL,'httx://search.justdial.com/');

curl_setopt($ch, CURLOPT_RETURNTRANSFER,1);

curl_setopt($ch, CURLOPT_USERAGENT, $_SERVER['HTTP_USER_AGENT']);

$result=curl_exec ($ch);

curl_setopt ($ch, CURLOPT_COOKIEJAR, $ckfile);

curl_setopt ($ch, CURLOPT_COOKIEFILE, $ckfile);

curl_setopt($ch, CURLOPT_URL,'httx://search.justdial.com/srch/all_indiasrch/all_india.php?page=1&companyname=a*&Allcity=All+India+Search');

curl_setopt($ch, CURLOPT_HTTPHEADERS,array('Host: search.justdial.com','Referer: httx://search.justdial.com/srch/all_indiasrch/all_india.php')); 

curl_setopt($ch, CURLOPT_RETURNTRANSFER,1);

curl_setopt($ch, CURLOPT_USERAGENT, $_SERVER['HTTP_USER_AGENT']);

$result=curl_exec ($ch);

preg_match('/\>([0-9].*?) Results for/',$result,$cnt);

$pages=$cnt[1];

preg_match_all('/javascript:showdetails_allindia\(\'([\s\S\w\W].*?)\',\'([\s\w\S\W].*?)\',\'sms\'\)/',$result,$details);

$i=0;

//foreach($details[1] as $i=>$v)

	{

	//post data to details page...

	curl_setopt ($ch, CURLOPT_COOKIEJAR, $ckfile);

	curl_setopt ($ch, CURLOPT_COOKIEFILE, $ckfile);

	curl_setopt($ch, CURLOPT_URL,'httx://search.justdial.com/srch/search_cmd.php?srch=true&sms=undefined&city='.$details[2][$i].'&define=+&value=');

	curl_setopt($ch, CURLOPT_RETURNTRANSFER,1);

	curl_setopt($ch, CURLOPT_USERAGENT, $_SERVER['HTTP_USER_AGENT']);

	curl_setopt($ch, CURLOPT_COOKIE, 'CITY='.$details[2][$i].'; ShowCity=;');

	curl_setopt($ch, CURLOPT_HTTPHEADERS,array('Host: search.justdial.com','Referer: httx://search.justdial.com/srch/all_indiasrch/all_india.php?page=1&companyname=a*&Allcity=All+India+Search')); 

	curl_setopt($ch, CURLOPT_POST, 1);

	curl_setopt($ch, CURLOPT_HEADER, TRUE);

	curl_setopt($ch, CURLOPT_POSTFIELDS,'city='.$details[2][$i].'&searchtype=&Stype=company&docId='.$details[1][$i].'&AllIndiaSearch=true&intermid='); 

	$result=curl_exec ($ch);

	echo $result;

	}

curl_close ($ch);

?>

this is the code that i am using...

the expected output is supposed to be the details of the first entry when you search for 'a*'...

Please help!

thnx!




1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users