Python petals Beauty Download

Source: Internet
Author: User

python petals Beauty Download

Author: VpoetDate: About in the summerNote: The code is free copy don't tell me
main functions:1. Search for pictures under petal http://huaban.com/2. Number of downloaded images selected3. Show Download Progress4. Create a directory and download it to the desktop
note Less, make a look.
#coding: Utf-8import urllib, URLLIB2, RE, sys, osimport randomreload (SYS) def Schedule (a,b,c): "" "A: Downloaded data block B: large chunk of data Small C: The size of the remote file "" "per = 100.0 * A * b/c if per > 100:per = + print '%.2f%% '% perdef searchanddown Loadimg (searchstr,numperpage,filepath): url = ' http://huaban.com/search/?q=%s&per_page=%s '% (Searchstr,str (Num perpage)) Respon = Urllib2.urlopen (URL) Htm = Respon.read () print url+ "\n\n\n" print "-------- --------Search over,and Begin DownLoad----------------"+" \ n "patt=re.compile ('" File ": \{" Farm ":" Farm1 ",. +?" Bucket ":" hbimg ",. +?" Key ":" (. *?) ",. +?" Type ":" image/(. *?) ",. +?" Width ": ') group = Re.findall (patt,htm) #print" Find Total Imgurl "+len (group) +" \ n "x = 1 for it EM in Group:imgurl=r "http://img.hb.aicdn.com/" +item[0]+ "_fw658" Urllib.urlretrieve (Imgurl,filep ath+ ' \pic%s.%s '% (str (x), item[1]), Schedule) print imgurl+ "------>down oveR "+" \tpic "+ str (x) x = x+1 if __name__ = =" __main__ ": print" Please input the picture you WA NT to download: "SEARCHSTR = Raw_input () print" \ n "print" Please input the pagenumber your want to Download: "Numperpage = Raw_input () print" \ n "print"-----------------------Begin Search---------- -----------------"+" \ n "filenum = random.randint (+) filename = ' picturefile ' +str (filenum) fi Lepath = ' C:\Users\Administrator\Desktop ' + ' \ \ ' +filename if (os.path.exists (filepath) = = False): Os.mkdir (file Path) #print filepath searchanddownloadimg (searchstr,numperpage,filepath) #http://IMG.HB.AICDN.COM/23 A58517FB73F86BCA85937F069724486B3E00A44CAA-GMC99I_SQ75SF print "\ n" print "---------------------all down Ov Er-----------------------"

Run:search beatuiful, download 20 photos
Petal Search Results:

Run, show download progress:
Image Crawl Results:


Python petals Beauty Download

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: info-contact@alibabacloud.com 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.