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