别的不多说,直接上代码:
#!usr/bin/python3
# -*-coding:UTF-8 -*-
import requests
import re
from collections import deque
url=‘‘
header={
‘User-Agent‘:‘Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/58.0.3029.110 Safari/537.36 Edge/16.16299‘
}
post_data={
}
cookies={}
queue=deque()
set=set()
def Get_one_page(num = 0):
for i in list(range(1,10000)):
url=‘https://mm.taobao.com/json/request_top_list.htm?page=‘+str(i)
print(url,end=‘\t‘)
try:
response=requests.get(url,headers=header,verify=False,timeout=2000)
except:
continue
demo=re.compile(‘<img.*?src="(.*?\.[jpgn]{3})".*?>‘,flags=0)
Img_src_list=re.findall(demo,response.content.decode(‘gbk‘))
for src in Img_src_list:
src=‘http:‘+src
try:
bin = requests.get(src).content
except:
continue
num += 1
path = ‘F:\\图片\\淘宝客服图片‘ + ‘\\\\‘ + str(num) + ‘.jpg‘
with open(path, ‘wb+‘) as fp:
fp.write(bin)
print(‘已取得%d张图片‘%num)
if __name__==‘__main__‘:
Get_one_page()