- 帖子
- 22
- 精华
- 0
- 积分
- 75
- 阅读权限
- 20
- 注册时间
- 2018-3-31
- 最后登录
- 2018-4-17
|
import urllib.request,time
time_start=time.time()
data=[]
for i in range(30):
print('reuest movie:',i)
id=1764796+i
url='https://api.douban.com/v2/movie/subject/%d'%id
d=urllib.request.urlopen(url).read()
data.append(d)
print(i,time.time()-time_start)
print('data',len(data))
运行结果如下:
reuest movie: 0
0 0.7348060607910156
reuest movie: 1
Traceback (most recent call last):
File "D:/Learning_Software/Python/Documents/CrossinLesson/lesson52_Multithrending.py", line 9, in <module>
d=urllib.request.urlopen(url).read()
File "D:\Learning_Software\Python\lib\urllib\request.py", line 223, in urlopen
return opener.open(url, data, timeout)
File "D:\Learning_Software\Python\lib\urllib\request.py", line 532, in open
response = meth(req, response)
File "D:\Learning_Software\Python\lib\urllib\request.py", line 642, in http_response
'http', request, response, code, msg, hdrs)
File "D:\Learning_Software\Python\lib\urllib\request.py", line 570, in error
return self._call_chain(*args)
File "D:\Learning_Software\Python\lib\urllib\request.py", line 504, in _call_chain
result = func(*args)
File "D:\Learning_Software\Python\lib\urllib\request.py", line 650, in http_error_default
raise HTTPError(req.full_url, code, msg, hdrs, fp)
urllib.error.HTTPError: HTTP Error 404: Not Found
好像能找到第一部,剩余的就找不到了,请问 是怎么回事
|
|