To a friend to do a crawl number of small programs, I use the following code to get no data, the header is set to 1, the following results
http/1.1 403 Forbidden accept-ranges:bytes Date:sat, Nov 03:11:05 GMT age:0 connection:close X-cache:miss
Here is the code, how can i solve it? Thank you.
$url = "http://www.btspread.com/search/abp108";
$ch =curl_init ();
curl_setopt ($ch, Curlopt_url, $url);
curl_setopt ($ch, curlopt_header,1);
curl_setopt ($ch, curlopt_returntransfer,1);
curl_setopt ($ch, curlopt_post,1);
echo $xml =curl_exec ($ch);
Curl_close ($ch);
?>
Reply to discussion (solution)
$headers [' user-agent '] = ' mozilla/5.0 (Macintosh; Intel Mac OS X 10.9; rv:33.0) gecko/20100101 firefox/33.0 '; $url = "http://www.btspread.com/search/%E9%A2%A8%E9%96%93"; $headerArr = Array ( ); foreach ($headers as $n = + $v) { $HEADERARR [] = $n. ': '. $v; } $ch =curl_init (); curl_setopt ($ch, Curlopt_url, $url); curl_setopt ($ch, curlopt_header,1); curl_setopt ($ch, Curlopt_ returntransfer,1) curl_setopt ($ch, Curlopt_httpheader, $HEADERARR), Echo $xml =curl_exec ($ch); Curl_close ($ch);
Thanks, LIJPWSW.