- 帖子
- 3
- 精华
- 0
- 积分
- 23
- 阅读权限
- 10
- 注册时间
- 2018-3-14
- 最后登录
- 2018-3-27
|
我用的是python3
这是代码
import urllib.request,time,_thread
def get_content(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))
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')
运行结果是这样的:
request movie: 0
request movie: 1
request movie: 2
request movie: 3
request movie: 4
request movie: 5
request movie: 6
request movie: 7
request movie: 8
request movie: 9
request movie: 10
request movie: 11
request movie: 12
request movie: 13
request movie: 14
request movie: 15
request movie: 16
request movie: 17
request movie: 18
request movie: 19
request movie: 20
request movie: 21
request movie: 22
request movie: 23
request movie: 24
request movie: 25
request movie: 26
request movie: 27
request movie: 28
request movie: 29
press ENTER to exit...
Unhandled exception in thread started by Unhandled exception in thread started by Unhandled exception in thread started by Unhandled exception in thread started by Unhandled exception in thread started by Unhandled exception in thread started by Unhandled exception in thread started by Unhandled exception in thread started by Unhandled exception in thread started by Unhandled exception in thread started by 63162021290Unhandled exception in thread started by 8Unhandled exception in thread started by Unhandled exception in thread started by 177Unhandled exception in thread started by 12224Unhandled exception in thread started by Unhandled exception in thread started by 2
>>> <function get_content at 0x062F8810><function get_content at 0x062F8810><function get_content at 0x062F8810><function get_content at 0x062F8810><function get_content at 0x062F8810><function get_content at 0x062F8810><function get_content at 0x062F8810><function get_content at 0x062F8810><function get_content at 0x062F8810><function get_content at 0x062F8810> <function get_content at 0x062F8810> <function get_content at 0x062F8810><function get_content at 0x062F8810> <function get_content at 0x062F8810> <function get_content at 0x062F8810><function get_content at 0x062F8810>
0.90009140968322750.90009140968322750.92193412780761720.92193412780761720.98459267616271970.98459267616271970.9845926761627197
1.0543501377105713
1.05435013771057131.0543501377105713
1.06997585296630861.06997585296630861.1386773586273193
1.3554306030273438Traceback (most recent call last):
Traceback (most recent call last):
Traceback (most recent call last):
Traceback (most recent call last):
Traceback (most recent call last):
Traceback (most recent call last):
Traceback (most recent call last):
Traceback (most recent call last):
Traceback (most recent call last):
Traceback (most recent call last):
Traceback (most recent call last):
Traceback (most recent call last):
Traceback (most recent call last):
Traceback (most recent call last):
Traceback (most recent call last):
Traceback (most recent call last):
File "D:\Program Files(X)\Python\个人文件\lesson74.py", line 6, in get_content
File "D:\Program Files(X)\Python\个人文件\lesson74.py", line 6, in get_content
File "D:\Program Files(X)\Python\个人文件\lesson74.py", line 6, in get_content
File "D:\Program Files(X)\Python\个人文件\lesson74.py", line 6, in get_content
File "D:\Program Files(X)\Python\个人文件\lesson74.py", line 6, in get_content
File "D:\Program Files(X)\Python\个人文件\lesson74.py", line 6, in get_content
File "D:\Program Files(X)\Python\个人文件\lesson74.py", line 6, in get_content
File "D:\Program Files(X)\Python\个人文件\lesson74.py", line 6, in get_content
File "D:\Program Files(X)\Python\个人文件\lesson74.py", line 6, in get_content
File "D:\Program Files(X)\Python\个人文件\lesson74.py", line 6, in get_content
data:data:data:data:data:data:data: File "D:\Program Files(X)\Python\个人文件\lesson74.py", line 6, in get_content
data: File "D:\Program Files(X)\Python\个人文件\lesson74.py", line 6, in get_content
File "D:\Program Files(X)\Python\个人文件\lesson74.py", line 6, in get_content
data:data: File "D:\Program Files(X)\Python\个人文件\lesson74.py", line 6, in get_content
data:data:data: File "D:\Program Files(X)\Python\个人文件\lesson74.py", line 6, in get_content
File "D:\Program Files(X)\Python\个人文件\lesson74.py", line 6, in get_content
data: 1414141414141414d=urllib.request.urlopen(url).read()d=urllib.request.urlopen(url).read()d=urllib.request.urlopen(url).read()d=urllib.request.urlopen(url).read()d=urllib.request.urlopen(url).read()d=urllib.request.urlopen(url).read()d=urllib.request.urlopen(url).read()d=urllib.request.urlopen(url).read()d=urllib.request.urlopen(url).read()d=urllib.request.urlopen(url).read()d=urllib.request.urlopen(url).read()d=urllib.request.urlopen(url).read()d=urllib.request.urlopen(url).read()1414d=urllib.request.urlopen(url).read()141414d=urllib.request.urlopen(url).read()d=urllib.request.urlopen(url).read()14
File "D:\Program Files(X)\Python\lib\urllib\request.py", line 223, in urlopen
File "D:\Program Files(X)\Python\lib\urllib\request.py", line 223, in urlopen
File "D:\Program Files(X)\Python\lib\urllib\request.py", line 223, in urlopen
File "D:\Program Files(X)\Python\lib\urllib\request.py", line 223, in urlopen
File "D:\Program Files(X)\Python\lib\urllib\request.py", line 223, in urlopen
File "D:\Program Files(X)\Python\lib\urllib\request.py", line 223, in urlopen
File "D:\Program Files(X)\Python\lib\urllib\request.py", line 223, in urlopen
File "D:\Program Files(X)\Python\lib\urllib\request.py", line 223, in urlopen
File "D:\Program Files(X)\Python\lib\urllib\request.py", line 223, in urlopen
File "D:\Program Files(X)\Python\lib\urllib\request.py", line 223, in urlopen
File "D:\Program Files(X)\Python\lib\urllib\request.py", line 223, in urlopen
File "D:\Program Files(X)\Python\lib\urllib\request.py", line 223, in urlopen
File "D:\Program Files(X)\Python\lib\urllib\request.py", line 223, in urlopen
File "D:\Program Files(X)\Python\lib\urllib\request.py", line 223, in urlopen
File "D:\Program Files(X)\Python\lib\urllib\request.py", line 223, in urlopen
File "D:\Program Files(X)\Python\lib\urllib\request.py", line 223, in urlopen
return opener.open(url, data, timeout) return opener.open(url, data, timeout) return opener.open(url, data, timeout)return opener.open(url, data, timeout)return opener.open(url, data, timeout)
return opener.open(url, data, timeout) return opener.open(url, data, timeout)return opener.open(url, data, timeout)
return opener.open(url, data, timeout)return opener.open(url, data, timeout)return opener.open(url, data, timeout)
|
|