Skip to content

Commit 9aa3c90

Browse files
committed
update test
1 parent 9e956d7 commit 9aa3c90

File tree

1 file changed

+21
-16
lines changed

1 file changed

+21
-16
lines changed

test.py

Lines changed: 21 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,10 @@ def parse():
2424
return qq, pwd
2525

2626

27-
def func(url, tp):
27+
def func(hostqq, url, tp):
2828
try:
2929
data = web.Request(url, type=tp)
30-
pic = file('%s/%s.%s' %(test_qq, str(random.random()), tp), 'wb')
30+
pic = file('%s/%s.%s' %(hostqq, str(random.random()), tp), 'wb')
3131
pic.write(data)
3232
pic.close()
3333
except Exception, e:
@@ -43,6 +43,23 @@ def multi(qq):
4343
s.wait_allfinish()
4444

4545

46+
def getAlbum(qq):
47+
48+
global test_qq
49+
test_qq = '' # 要爬取人的qq号, 不写默认为空。
50+
qq.getAlbumList(test_qq)
51+
# qq.getAlbumList() 无参数默认爬取自己的相册
52+
53+
if len(qq.picUrl) < 2:
54+
print 'few pictures'
55+
else:
56+
if test_qq == '':
57+
test_qq = qq.qq # 默认是自己的号码
58+
if not os.path.exists(test_qq):
59+
os.mkdir(test_qq)
60+
multi(qq)
61+
62+
4663
def login():
4764
method = raw_input('选择方式登录:1.二维码;2.帐号密码;\n')
4865
if method == '1':
@@ -60,17 +77,5 @@ def login():
6077

6178
if __name__ == '__main__':
6279

63-
qq = login()
64-
global test_qq
65-
test_qq = '' # 要爬取人的qq号, 不写默认为空。
66-
qq.getAlbumList(test_qq)
67-
# qq.getAlbumList() 无参数默认爬取自己的相册
68-
69-
if len(qq.picUrl) < 2:
70-
print 'few pictures'
71-
else:
72-
if test_qq == '':
73-
test_qq = qq.qq # 默认是自己的号码
74-
if not os.path.exists(test_qq):
75-
os.mkdir(test_qq)
76-
multi(qq)
80+
qq = login() # 登录入口
81+
getAlbum(qq) # 获取相册

0 commit comments

Comments
 (0)