The loading of petals pictures using the technology of lazy loading, the source code can only download more than 20 pictures, modified basic can download all, just a bit slow, back to optimize under
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 = Urllib 2.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) + ' &am p;limit= ' + str + ' &wfl=1 ' Print (urltemp) groups = Urlhandle (urltemp) #print groups Imghandle (groups)