1
我有一个开发代号的一部分,我从网页抓取使用:的urlopen [错误-2] Python的
link = 'http://www.cmegroup.com'+div.findAll('a')[3]['href']
user_agent = 'Mozilla/5.0'
headers = {'User-Agent':user_agent}
req = urllib2.Request(link, headers=headers)
page = urllib2.urlopen(req).read()
但是我不明白的是,有时我得到一个错误请求链接。但有时候,我不知道。例如,错误:
urllib2.URLError: <urlopen error [Errno -2] Name or service not known>
出来了此链接:
http://www.cmegroup.com/trading/energy/refined-products/mini-european-naphtha-platts-cif-nwe-swap-futures_product_calendar_futures.html
当我重新运行代码,我不会再得到该链接的错误,但是对于其他一些。 这可能是由于无线连接?