- 帖子
- 10
- 精华
- 0
- 积分
- 41
- 阅读权限
- 10
- 注册时间
- 2017-1-25
- 最后登录
- 2017-2-13
|
#后来查找资料和AAA助教的协助我这样写了
import urllib2
url = 'https://api.douban.com/v2/movie/subject/1764796'
headers={
'User-Agent':'Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/54.0.2840.59 Safari/537.36'
}
data=None
req=urllib2.Request(url,data,headers)#构造请求信息
res=urllib2.urlopen(req)#发送构造请求信息
html=res.read()
print html
#但是爆了这个错
Traceback (most recent call last):
File "C:\Python27\test\testdeencode.py", line 36, in <module>
res=urllib2.urlopen(req)#发送构造请求信息
File "C:\Python27\lib\urllib2.py", line 126, in urlopen
return _opener.open(url, data, timeout)
File "C:\Python27\lib\urllib2.py", line 391, in open
response = self._open(req, data)
File "C:\Python27\lib\urllib2.py", line 409, in _open
'_open', req)
File "C:\Python27\lib\urllib2.py", line 369, in _call_chain
result = func(*args)
File "C:\Python27\lib\urllib2.py", line 1181, in https_open
return self.do_open(httplib.HTTPSConnection, req)
File "C:\Python27\lib\urllib2.py", line 1148, in do_open
raise URLError(err)
URLError: <urlopen error [Errno 10060] >
|
|