Skip to content

Commit 7ebded0

Browse files
committed
Create 0013.py
1 parent 340d901 commit 7ebded0

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed

Liez-python-code/0013/0013.py

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
# 网址:http://tieba.baidu.com/p/4341640851
2+
3+
import os
4+
import re
5+
import urllib.request
6+
7+
def pic_collector(url):
8+
content = urllib.request.urlopen(url).read()
9+
r = re.compile('<img class="BDE_Image" pic_type="1" width="450" height="450" src="(.*?)" ')
10+
pic_list = r.findall(content.decode('utf-8'))
11+
12+
os.mkdir('pic_collection')
13+
os.chdir(os.path.join(os.getcwd(), 'pic_collection'))
14+
for i in range(len(pic_list)):
15+
pic_num = str(i) + '.jpg'
16+
urllib.request.urlretrieve(pic_list[i], pic_num)
17+
print("success!" + pic_list[i])
18+
19+
pic_collector("http://tieba.baidu.com/p/4341640851")

0 commit comments

Comments
 (0)