Reputation: 6305
i have some simple situation, but for me, it looks like very tough at the moment.
I am trying to scrap a web, which uses AJAX calls to fetch data.
has a form, after checking appropriate options, and pressing submit
button. an ajax call is send and in response, data is printed on the page. there is NO JSON involved in this.
Using firebug and web developer tools, I am able to see referral URL, params, and cookie and other stuff involved, request header in Firebug looks like
Accept text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
Accept-Encoding gzip, deflate
Accept-Language en-us,en;q=0.5
Connection keep-alive
Cookie JSESSIONID=cYJtPcYGYs2dM12QXgD3vGfnnQFVX3cTzfFbYLwWBkmXv4m47jh1!924382716
Host www.economia-nmx.gob.mx
Referer http://www.economia-nmx.gob.mx/normasmx/index.nmx
User-Agent Mozilla/5.0 (Windows NT 5.1; rv:11.0) Gecko/20100101 Firefox/11.0
consultasvarias.nmx http://www.economia-nmx.gob.mx/normasmx/consulta.nmx
can somebody please tell me, how can I CURL the page (in php)?
what data I MUST send in CURl?
OR i have to generate full request header?
what are the CURL options I must set for this?
Guide me please and thanks for the help..
Upvotes: 0
Views: 1364
Reputation: 2258
You should just try to mimic the ajaxrequest.
The parameters you can mimic with:
$data = array('name' => 'Foo', 'id'=>'Bar');
curl_setopt($ch, CURLOPT_URL, 'http://localhost/upload.php');
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
You could start out by checking the phpmanual on curl
Upvotes: 1