0
我有像這樣運行的API:爲什麼curl無法獲得與ie瀏覽器相同的響應?
,所以我想用curl
得到的結果在我的ubuntu
的機器,那我試試這個:
curl -v \
--header 'Accept: text/html, application/xhtml+xml, */*' \
--header 'Accept-Language: zh-CN' \
-A 'Mozilla/5.0 (Windows NT 6.1; WOW64; Trident/7.0; rv:11.0) like Gecko' \
--header 'Accept-Encoding: gzip, deflate' \
--header 'Host: 10.202.15.197:20176' \
--header 'DNT: 1' \
--header 'Connection: Keep-Alive' \
http://10.202.15.197:20176?user_id=1&query_type=GEOSPLIT&address=廣東省深圳市寶安&ret_splitinfo=1
然後發生了奇怪的事情:正如你所看到的,我得到了完全不同的結果,即browswer,所以我想這一定是編碼的問題,那我試試這個:
curl -v \
--header 'Accept: text/html, application/xhtml+xml, */*' \
--header 'Accept-Language: zh-CN' \
-A 'Mozilla/5.0 (Windows NT 6.1; WOW64; Trident/7.0; rv:11.0) like Gecko' \
--header 'Accept-Encoding: gzip, deflate' \
--header 'Host: 10.202.15.197:20176' \
--header 'DNT: 1' \
--header 'Connection: Keep-Alive' \
http://10.202.15.197:20176 --data-urlencode 'user_id=1&query_type=GEOSPLIT&address=廣東省深圳市寶安&ret_splitinfo=1'
,但沒有,它返回相同的結果,我通過fiddler
趕上我的請求,我的窗口,即瀏覽器,我得到的請求數據:
GET http://10.202.15.197:20176/?user_id=1&query_type=GEOSPLIT&address=廣東省深圳市寶安&ret_splitinfo=1 HTTP/1.1
Accept: text/html, application/xhtml+xml, */*
Accept-Language: zh-CN
User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; Trident/7.0; rv:11.0) like Gecko
Accept-Encoding: gzip, deflate
Host: 10.202.15.197:20176
DNT: 1
Connection: Keep-Alive
Pragma: no-cache
HTTP/1.0 200 OK
Content-Type: application/octet-stream
Connection: close
Content-Length: 222
<?xml version='1.0' encoding='GBK'?>
<addrSplitInfo>
<status>0</status><as_info prop="1" level="1">廣東省</as_info>
<as_info prop="1" level="2">深圳市</as_info>
<as_info prop="3" level="18">寶安</as_info>
</addrSplitInfo>
嗨,提示:菲德勒使用代理服務器連接....關閉您的代理在IE的網絡設置。 –