与curl脚本输出“ *来自服务器的空回复”连接,但是Fiddler可以获取数据

时间:2019-08-13 14:32:50

标签: curl fiddler

当我使用提琴手4时,可以捕获以下链接:

http://www.win0168.com/vbsxml/goalBf3.xml?r=0071565705912000

具有以下 RAW 标头:

GET http://www.win0168.com/vbsxml/sbOddsData.js?r=0071565706079000 HTTP/1.1
Host: www.win0168.com
User-Agent: Mozilla/5.0 (Windows NT 6.3; Win64; x64; rv:68.0) Gecko/20100101 Firefox/68.0
Accept: */*
Accept-Language: zh-TW,zh;q=0.8,en-US;q=0.5,en;q=0.3
Accept-Encoding: gzip, deflate
Referer: http://www.win0168.com/
Connection: keep-alive
Cookie: win007BfCookie=null; bfWin007FirstMatchTime=2019,7,13,08,00,00; UM_distinctid=16c8b3edbf14fc-062d46919e565-14367b40-190140-16c8b3edbf22e7; win0168BfFavoriteCookie=1

提琴手4的输出

sData[1743630]=[[0.98,0,0.86,0.82,0.25,1.04,,,],[2.55,3.20,2.40,2.07,3.35,3.15,,,],[0.88,2.25,0.94,1.03,2.5,0.81,,,],[0.90,0,0.94,1.23,0.25,0.67,,,],[1.06,1.00,0.76,1.04,1,0.80,,,],[3.15,2.03,3.20,2.69,2.08,3.70,,,]];

但是当我用curl执行以下脚本时:

curl -vvv 'http://www.win0168.com/vbsxml/goalBf3.xml?r=0071565705912000' -H 'Referer: http://www.win0168.com/'

curl的输出(Windows cmd shell):

curl -vvv 'http://www.win0168.com/vbsxml/goalBf3.xml?r=0071565705912000' -H 'Referer: http://www.win0168.com/'
* Could not resolve host: 'http
curl: (6) Could not resolve host: 'http
*   Trying 47.75.149.10:80...
* TCP_NODELAY set
* Connected to www.win0168.com (47.75.149.10) port 80 (#1)
> GET /' HTTP/1.1
> Host: www.win0168.com
> User-Agent: curl/7.65.3
> Accept: */* 
>
* Recv failure: Connection was reset
* Closing connection 1
curl: (56) Recv failure: Connection was reset

curl(Linux shell)的输出:

root@xxxxx:~# curl -vvv 'http://www.win0168.com/vbsxml/goalBf3.xml?r=0071565705912000' -H 'Referer: http://www.win0168.com/'
*   Trying 47.52.91.249...
* TCP_NODELAY set
* Connected to www.win0168.com (47.52.91.249) port 80 (#0)
> GET /vbsxml/goalBf3.xml?r=0071565705912000 HTTP/1.1
> Host: www.win0168.com
> User-Agent: curl/7.58.0
> Accept: */*
> Referer: http://www.win0168.com/
>
* Recv failure: Connection reset by peer
* stopped the pause stream!
* Closing connection 0
curl: (56) Recv failure: Connection reset by peer

1 个答案:

答案 0 :(得分:1)

win0168.com阻止卷曲。该块是通过User-Agent标头检测实现的。要么使用wget,要么设置一个不包含短语“ curl”的伪造的useragent。作为记录,您的curl的User-Agent是

   ->add ( 'someField' , ChoiceType::class , [
        'placeholder' => 'Select a field' ,
        'choice_label' => this->getChoicesForAppId() );

但是如果您将UA的curl名称取反,则会得到响应,

User-Agent: curl/7.65.3

({curl -A 'lruc' -H 'Referer: http://www.win0168.com/' 'http://www.win0168.com/vbsxml/goalBf3.xml?r=0071565705912000' lruc向后写。)