更新时间:2023-09-16 12:52:58
我不确定您需要Cookie的什么,但是问题是Web服务器正在阻止对请求标头中urllib发送的用户代理的访问(类似于-'Python-urllib/2.7'
之类的东西).
I am not sure what you need cookies for, but the issue is that the webserver is blocking access to the user-agent being sent by urllib in the request header (which is something like - 'Python-urllib/2.7'
or so) .
您应该在标题中添加有效的浏览器用户代理,以获取正确的数据.示例-
You should add a valid browser User-agent to the header to get the correct data. Example -
import urllib2
url = "http://lhr.data.fr24.com/_external/planedata_json.1.3.php?f=72c5ef5"
req = urllib2.Request(url, headers={"Connection":"keep-alive", "User-Agent":"Mozilla/5.0"})
response = urllib2.urlopen(req)
jsondata = response.read()