爬取花瓣网美女图片

爬取花瓣网美女图片,第1张

概述爬取花瓣美女图片

下面是内存溢出 jb51.cc 通过网络收集整理的代码片段。

内存溢出小编现在分享给大家,也给大家做个参考。

import urllib,urllib2,re,sys,os,requestspath=r"C:\wqa\beautify"url = 'http://huaban.com/favorite/beauty'#http://huaban.com/explore/zhongwenlogo/?ig1un9tq&max=327773629&limit=20&wfl=1i_headers = {"User-Agent": "Mozilla/5.0 (windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML,like Gecko) Chrome/46.0.2490.71 Safari/537.36"}count=0def urlHandle(url):    req = urllib2.Request(url,headers=i_headers)    HTML = urllib2.urlopen(req).read()    reg = re.compile(r'"pin_ID":(\d+),.+?"file":{"farm":"farm1","bucket":"hbimg",.+?"key":"(.*?)",.+?"type":"image/(.*?)"',re.S)    groups = re.findall(reg,HTML)    return groupsdef imgHandle(groups):    if groups:        for att in groups:                pin_ID = att[0]            att_url = att[1] + '_fw236'            img_type = att[2]            img_url = 'http://img.hb.aicdn.com/' + att_url                    r = requests.get(img_url)            with open(path + att_url + '.' + img_type,'wb') as fd:                for chunk in r.iter_content():                    fd.write(chunk)groups = urlHandle(url)imgHandle(groups)while(groups):    count+=1    print count    pin_ID  = groups[-1][0]    print pin_ID    urltemp = url+'/?max=' + str(pin_ID) + '&limit=' + str(20) + '&wfl=1'    print(urltemp)    groups = urlHandle(urltemp)    #print groups    imgHandle(groups)

以上是内存溢出(jb51.cc)为你收集整理的全部代码内容,希望文章能够帮你解决所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

总结

以上是内存溢出为你收集整理的爬取花瓣网美女图片全部内容,希望文章能够帮你解决爬取花瓣网美女图片所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

欢迎分享,转载请注明来源:内存溢出

原文地址: https://outofmemory.cn/langs/1199095.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-06-04
下一篇 2022-06-04

发表评论

登录后才能评论

评论列表(0条)

保存