Bing Crawler Source Code

Source: Internet
Author: User

Bingbong architecture uses MFC to handle UI building, configuration processing, Python implementation of the Crawler module architecture. When called, the corresponding parameters are passed into the crawler module, and then the crawler begins to download.

Python code is relatively simple, time-consuming instead of looking for a variety of third-Library information AH ~

#! C:\Python27\python#-*-coding:utf-8-*-ImportString,urllib2,re,time,sysImportWin32API, Win32con, Win32guiImportImage#Main functiondefBingbong (Path,cho): Response= Urllib2.urlopen ('http://cn.bing.com/') HTML=response.read () pattern= Re.compile (r'http://s.cn.bing.net'+'. *?\.jpg') Match=pattern.search (HTML)ifmatch:#print U ' picture search succeeded! '        #print Match.group ()conn =Urllib2.urlopen (Match.group ()) Date= Time.strftime ('%y-%m-%d', Time.localtime (Time.time ())) Jpgpath= path + Date +'. jpg'F= Open (Jpgpath,'WB') F.write (Conn.read ()) F.close ()ifCho:setwallpaper (jpgpath,sys.argv[3] )                #print u ' picture Saved! '    Else:        PrintU'Image search failed! '        defsetwallpaperfrombmp (ImagePath): K= Win32API. RegOpenKeyEx (Win32con. HKEY_CURRENT_USER,"Control panel\\desktop", 0,win32con. Key_set_value) Win32API. RegSetValueEx (k,"Wallpaperstyle", 0, Win32con. REG_SZ,"2")#2 stretch fit desktop, 0 Desktop centerWin32API. RegSetValueEx (k,"Tilewallpaper", 0, Win32con. REG_SZ,"0") Win32gui. SystemParametersInfo (Win32con. Spi_setdeskwallpaper,imagepath,1+2)        #convert JPG to BMPdefSetWallpaper (Imagepath,savepath): Bmpimage=Image.open (ImagePath)#NewPath = Imagepath.replace ('. jpg ', '. bmp ')Bmpimage.save (Savepath,"BMP") setwallpaperfrombmp (Savepath)#print U ' Please enter the path to save the picture: 'Path = sys.argv[1]cho= Int (sys.argv[2]) Bingbong (Path,cho)

Bing Crawler Source Code

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.