forked from Show-Me-the-Code/python
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path0013.py
More file actions
19 lines (15 loc) · 620 Bytes
/
0013.py
File metadata and controls
19 lines (15 loc) · 620 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
# 网址:http://tieba.baidu.com/p/4341640851
import os
import re
import urllib.request
def pic_collector(url):
content = urllib.request.urlopen(url).read()
r = re.compile('<img class="BDE_Image" pic_type="1" width="450" height="450" src="(.*?)" ')
pic_list = r.findall(content.decode('utf-8'))
os.mkdir('pic_collection')
os.chdir(os.path.join(os.getcwd(), 'pic_collection'))
for i in range(len(pic_list)):
pic_num = str(i) + '.jpg'
urllib.request.urlretrieve(pic_list[i], pic_num)
print("success!" + pic_list[i])
pic_collector("http://tieba.baidu.com/p/4341640851")