标题: 求助:74课报错:urllib.error.HTTPError: HTTP Error 404: Not Found [打印本页] 作者: Ambition——xb 时间: 2018-4-10 16:58 标题: 求助:74课报错:urllib.error.HTTPError: HTTP Error 404: Not Found 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
time_start=time.time()
data=[]
for i in range(30):
print('request movie:',i)
_thread.start_new_thread(get_content,(i,))
input('press ENTER to exit...\n')
我按照这位同学的写了写,然后发现错误如下:
Traceback (most recent call last):
File "C:/Users/boding/Desktop/Python/lesson74.py", line 18, in <module>
_thread._start_new_thread(get_content,(i,))
AttributeError: 'module' object has no attribute '_start_new_thread'