python请求模块和cu的结果不同

2024-09-26 22:49:56 发布

您现在位置:Python中文网/ 问答频道 /正文

当使用CURL时,我得到了结果。它是一个302 redirect。在

hhr@hhr:~$ curl -I http://www.vevo.com/watch/kesha/crazy-kids/USRV81300226
HTTP/1.1 302 Moved Temporarily
Content-Length: 159
Content-Type: text/html; charset=utf-8
Location: http://www.youtube.com/watch?v=xdeFB7I0YH4
Server: Microsoft-IIS/7.0
X-AspNetMvc-Version: 3.0
X-AspNet-Version: 4.0.30319
X-Powered-By: ASP.NET
Access-Control-Allow-Origin: *
Expires: Mon, 17 Jun 2013 15:33:41 GMT
Cache-Control: max-age=0, no-cache, no-store
Pragma: no-cache
Date: Mon, 17 Jun 2013 15:33:41 GMT
Connection: keep-alive

当使用Python requests模块时,结果如下所示。它是一个200 ok。在

^{pr2}$

以及输出:

status_code:  200
response_url:  http://www.vevo.com/watch/kesha/crazy-kids/USRV81300226
headers: 
{'access-control-allow-origin': '*',
 'cache-control': 'max-age=0, no-cache, no-store',
 'connection': 'keep-alive',
 'content-encoding': 'deflate',
 'content-length': '12310',
 'content-type': 'text/html; charset=utf-8',
 'date': 'Mon, 17 Jun 2013 16:17:35 GMT',
 'expires': 'Mon, 17 Jun 2013 16:17:35 GMT',
 'pragma': 'no-cache',
 'server': 'Microsoft-IIS/7.0',
 'vary': 'Accept-Encoding',
 'via': 'HTTP/1.1 GWA',
 'x-aspnet-version': '4.0.30319',
 'x-aspnetmvc-version': '3.0',
 'x-powered-by': 'ASP.NET'}
history:  []

为什么结果不同?在

为了使用Python获得CURL输出中的Location: http://www.youtube.com/watch?v=xdeFB7I0YH4值,我该怎么做?在


Tags: nocomhttpcachewwwcontentcurljun

热门问题