I am trying to use cURL and SimpleHtmlDom to post a 13-digit value and pull some data from this site :
http://www.hcad.org/records/Real.asp?search=acct
After posting a 13-digit value i want to get this redirected page :
http://www.hcad.org/records/details.asp?crypt=%94%9A%B0%94%BFg%85%8E%84%82pg%8El%88tXt%5FW%9E%99%A2%D3%89%95%C2e%7CU%8A%7D%86%C0%AB%A8%AD%86%5E&bld=1&tab=
on which i will apply simplehtmldom to parse some data
i have searched some site to make this code snippet
<?php
$urltopost = "http://www.hcad.org/records/Real.asp?search=acct";
$datapost = array(
"searchval" => "1158830010007",
);
$ch = curl_init ($urltopost);
curl_setopt ($ch, CURLOPT_POST, true);
curl_setopt ($ch, CURLOPT_POSTFIELDS, $datatopost);
curl_setopt ($ch, CURLOPT_RETURNTRANSFER, true);
$returndata = curl_exec ($ch);
echo $returndata;
?>
but its not providing me the redirected page i want .
what should i do now to do it correctly ?? waiting for any kind of help .
Thanks in advance
You need to set the
CURLOPT_FOLLOWLOCATIONoption for the curl to follow a redirect or it just returns the page data (if any) without redirecting.Edit: I have looked at the source code on the page, you should modify your code accordingly:
You should have been posting to the page that the form submits to (see above
$urltopost). Also, you should use a query string as your post data.