码迷,mamicode.com
首页 > 其他好文 > 详细

爬淘宝店铺MM的头像图片

时间:2017-12-26 00:55:54      阅读:214      评论:0      收藏:0      [点我收藏+]

标签:淘宝客   headers   mpi   https   html   blog   code   data   demo   

别的不多说,直接上代码:

 

#!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()

爬淘宝店铺MM的头像图片

标签:淘宝客   headers   mpi   https   html   blog   code   data   demo   

原文地址:https://www.cnblogs.com/jiangxiaochuan/p/8111626.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!