import requests
import re
from urllib import request
for n in range(15):
a_url = 'http://www.xiaohuar.com/list-1-'+str(n)+'.html'
html_1 = requests.get(a_url)
html_1.encoding = 'gb2312'
#print(html_1.text) #查看网页源代码
detail_list1=re.findall(r'/d/file/.*?\.\w+',html_1.text)
for url in detail_list1:
urls = 'http://www.xiaohuar.com'+url
html_2=requests.get(urls)
img_data=html_2.content
#print(img_data)
img = urls.split('/')[-1]
with open(r'F:\spider\322\%s' % img,'wb') as f:
import re
from urllib import request
for n in range(15):
a_url = 'http://www.xiaohuar.com/list-1-'+str(n)+'.html'
html_1 = requests.get(a_url)
html_1.encoding = 'gb2312'
#print(html_1.text) #查看网页源代码
detail_list1=re.findall(r'/d/file/.*?\.\w+',html_1.text)
for url in detail_list1:
urls = 'http://www.xiaohuar.com'+url
html_2=requests.get(urls)
img_data=html_2.content
#print(img_data)
img = urls.split('/')[-1]
with open(r'F:\spider\322\%s' % img,'wb') as f:
f.write(img_data) #写入文件
#结果如下: