Python Make flower petal net beautiful picture crawler

Source: Internet
Author: User
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:// = {"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 = '' + 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)
  • Related Article

    Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.