python requests爬取图片,用request库python爬取图片
importrequestsimportosfrombs 4 importbeautifulsouimportre #初始地址all _ URL= http://www.7160.com/Xiaohua/ #保存路径path= h wow 64 苹果WebKit/537.36(khtml,像壁虎(铬/50。0 .2661 .102 ubrowser/6。1 .2107 .204 safari/537.36 headers=header(start _ html=html。文字。编码(iso-8859-1))将gb2312转换为UTF-8格式### lxml ) #最大页码page=255#相同路径same _ URL= http://www。7118 int(page)1):ul=same _ URL list _ 6 _ str(n开始请求(单列表多因素headers=header(start _ html=html。文字。编码(iso-8859-1).decode)# # # # soup=beaup) lxml )all _ a=soup。find)、class_=news_bom-left ).芬NND= :# # # # # # # # # 3360的目录如果(OS。路径。存在(路径标题。strip)).替换)?)):# print(目录已存在()flag=1 else:OS。制作目录(路径标题。剥离).替换( )flag=0OS.chdir(pathtitle.strip().替换)(?)## # # # # # # # # # # # # # # # # # # # # # # # # # # # # # in _ URL= http://www.7160.com href=in _ URL hrefs html=requests。get(headers=header(html=html。文字。ext))titles=mess。找到(H1).textpic_max=mess.find)、class_=itempage ).find_all 、"( int(pic))int)pic _ max)1)3360 href=a href(href().join)href)ifnum==1:html=in _ URL href).html else 3: ###开始请求(单个元素中子元素(# # # # # htmls=requests.get ) html,headers=header(html=html s . text。编码(iso-8859-1).decode(gbk))# # # # # # # # # # # # lxml )pic _ URL)alt=titles(print(pic _ URL[ src )(# # # # # # # # # # # # # # # # #
准备攀登:
阳光下校花减肥的故事魅惑桃花的眼睛
img.7160.com/uploads/allimg/180913/13-1p913102541.jpg街3358号
img.7160.com/uploads/allimg/180913/13-1p913102541-50.jpg街3358号
img.7160.com/uploads/allimg/180913/13-1p913102541-51.jpg街3358号
img.7160.com/uploads/allimg/180913/13-1p913102542.jpg街3358号
img.7160.com/uploads/allimg/180913/13-1p913102542-50.jpg街3358号
img.7160.com/uploads/allimg/180913/13-1p913102542-51.jpg街3358号
img.7160.com/uploads/allimg/180913/13-1p913102542-52.jpg街3358号
img.7160.com/uploads/allimg/180913/13-1p913102542-53.jpg街3358号
img.7160.com/uploads/allimg/180913/13-1p913102542-54.jpg街3358号
img.7160.com/uploads/allimg/180913/13-1p913102543.jpg街3358号
img.7160.com/uploads/allimg/180913/13-1p913102543-50.jpg街3358号
完成
准备攀登:
黑直发减肥的故事学生日系风制服
img.7160.com/uploads/allimg/180912/13-1p912102159.jpg街33558号
img.7160.com/uploads/allimg/180912/13-1p912102159-50.jpg街33558号
img.7160.com/uploads/allimg/180912/13-1p912102159-51.jpg街33558号
img.7160.com/uploads/allimg/180912/13-1p912102159-52.jpg街33558号
img.7160.com/uploads/allimg/180912/13-1p912102200.jpg街3358号
转载于字体blogs.com/zhuifeng-Mayi/p/9712209.html
郑重声明:本文由网友发布,不代表盛行IT的观点,版权归原作者所有,仅为传播更多信息之目的,如有侵权请联系,我们将第一时间修改或删除,多谢。