http://fuzhou.8684.cn/
My code is like this.
' */* ', ' accept-charset ' = ' utf-8,*;q=0.5 ', ' accept-encoding ' = ' gzip,deflate,sdch ', ' accept-language ' =&G T ' zh-cn,zh;q=0.8 ', ' Connection ' = ' keep-alive ', ' content-type ' = ' application/x-www-form-urlencoded; Charset=utf-8 ', ' Referer ' = ' http://fuzhou.8684.cn/', ' user-agent ' = ' mozilla/5.0 ' (Windows NT 5.1) APPLEWEBK it/537.11 (khtml, like Gecko) chrome/23.0.1271.95 safari/537.11 ', ' x-requested-with ' = ' XMLHttpRequest ',)); $dat = C Url_exec ($ch); Var_dump (Curl_error ($ch));//curl_close ($ch); Var_dump ($dat);//var_dump (Curl_error ($ch));
But the output is
String (Reply) "Empty from server" bool (FALSE)
Reply content:
http://fuzhou.8684.cn/
My code is like this.
' */* ', ' accept-charset ' = ' utf-8,*;q=0.5 ', ' accept-encoding ' = ' gzip,deflate,sdch ', ' accept-language ' =&G T ' zh-cn,zh;q=0.8 ', ' Connection ' = ' keep-alive ', ' content-type ' = ' application/x-www-form-urlencoded; Charset=utf-8 ', ' Referer ' = ' http://fuzhou.8684.cn/', ' user-agent ' = ' mozilla/5.0 ' (Windows NT 5.1) APPLEWEBK it/537.11 (khtml, like Gecko) chrome/23.0.1271.95 safari/537.11 ', ' x-requested-with ' = ' XMLHttpRequest ',)); $dat = C Url_exec ($ch); Var_dump (Curl_error ($ch));//curl_close ($ch); Var_dump ($dat);//var_dump (Curl_error ($ch));
But the output is
String (Reply) "Empty from server" bool (FALSE)
I can only say that your curl
manual is not serious, the CURLOPT_HTTPHEADER
use of this option must be in your own imagination, in fact, it is not so, should
curl_setopt ($ch, Curlopt_httpheader, Array ( ' Accept: */* ', ' accept-charset:utf-8,*;q=0.5 ', ' Accept-encoding:gzip,deflate,sdch ', ' accept-language:zh-cn,zh;q=0.8 ', ' connection:keep-alive ', ' content-type:application/x-www-form-urlencoded; Charset=utf-8 ', ' referer:http://fuzhou.8684.cn/', ' user-agent:mozilla/5.0 (Windows NT 5.1) applewebkit/ 537.11 (khtml, like Gecko) chrome/23.0.1271.95 safari/537.11 ', ' x-requested-with:xmlhttprequest ',));
So read the manual carefully.
Add up. It was intended to use curl+ to collect 8684 of the data.
Later found that love to help the network has a free bus data API.
http://www.aibang.com/api/
Check out the PHP manual.
Landlord will code:
curl_setopt ($ch, Curlopt_httpheader, Array ( ' Accept ' = = ' */* ', ' accept-charset ' = ' utf-8,*;q=0.5 ', ' accept-encoding ' = ' gzip,deflate,sdch ', ' accept-language ' = ' zh-cn,zh;q=0.8 ', ' Connection ' = > ' keep-alive ', ' content-type ' = ' application/x-www-form-urlencoded ', Charset=utf-8 ', ' Referer ' = ' http://fuzhou.8684.cn/', ' user-agent ' = ' mozilla/5.0 (Windows NT 5.1) applewebkit/537.11 (khtml, like Gecko) chrome/23.0.1271.95 safari/537.11 ', ' x-requested-with ' = ' XMLHttpRequest ',));
Call the function curl_setopt Replace with Curl_setopt_array to try.
Curl does have a powerful function! I used to use Fsocket to send HTTP requests in the program, and then after trying curl, it felt convenient and much more flexible!
A blog post about curl, though simple, feels good!
Http://www.360weboy.com/web-service/c ...