Skip to content

Commit c18ef4c

Browse files
committed
update one_img.py
1 parent 6e98a48 commit c18ef4c

File tree

1 file changed

+27
-8
lines changed

1 file changed

+27
-8
lines changed

spiderFile/one_img.py

Lines changed: 27 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,37 @@
11
import re
22
import requests
33

4-
temp = 'http://caodan.org/page/'
4+
temp = 'http://wufazhuce.com/one/'
55
count = 1
6-
for i in range(1, 1331):
6+
for i in range(14, 1580):
77
url = temp + str(i)
88
page = requests.get(url).text
99
reg = re.compile('src="(http://.*?\.jpg)"')
1010
img_url = re.findall(reg, page)
1111
if img_url != []:
12-
with open('E:/img/%s.jpg' % count, 'wb') as file:
13-
img_data = requests.get(img_url[0]).content
14-
file.write(img_data)
15-
count += 1
16-
else:
17-
continue
12+
with open('./{}.jpg'.format(count), 'wb') as file:
13+
try:
14+
img_data = requests.get(img_url[0]).content
15+
file.write(img_data)
16+
count += 1
17+
except:
18+
pass
1819
print('OK!')
20+
21+
22+
23+
24+
25+
26+
27+
28+
29+
30+
31+
32+
33+
34+
35+
36+
37+

0 commit comments

Comments
 (0)