wtfx.tk is a website that shares the free SS account, but he shares only the QR Code. And the latest version of the SS can not scan the two-dimensional code on the page, so it is very troublesome to download the Picture. So I specifically wrote a crawler to save the QR code on the site to a local folder.
The crawler will delete the Pic folder under the relative path and create a new pic folder to store the QR Code. Please use it with Caution.
If there is no Pic folder under the relative path, the crawler will prompt and press Enter to Continue.
The source code is as Follows:
1 #Coding:utf-82 __author__='Liuqi'3 ImportOS4 ImportRe5 ImportSYS6 ImportCopy7 ImportShutil8 ImportUrllib9 ImportChardetTen one defgethtml (url): apage =Urllib.urlopen (url) -HTML =Page.read () - returnHTML the - defgetpngaddr (html): -PNG = R"Pic/\w+[-]?\w+[-]?\w*\.png" -TMP =re.compile (png) +PNG =Re.findall (tmp, Html) - #Print PNG + forIinchRange (len (png)): apng[i] = URL +png[i] at - returnPNG - - defgetpngname (pngaddr): -Pngname =copy.deepcopy (pngaddr) - inPngt = R'pic/(\w+[-]?\w+[-]?\w*) \.' -t =re.compile (pngt) to forIinchRange (len (pngaddr)): +pngname[i] =re.findall (t, pngaddr[i]) [0] - the returnPngname * $ defgetpng (Addr, Name):Panax NotoginsengUrllib.urlretrieve (Addr,"Pic\\%s.png"%Name) - the + if __name__=="__main__": aURL ='http://wtfx.tk/' the +HTML =gethtml (url) - $PNGADDR =getpngaddr (html) $ #Print Pngaddr -Pngname =getpngname (pngaddr) - the #os.rmdir (' pic ') - Try:WuyiShutil.rmtree ('pic') the exceptwindowserror, E: - Print "couldn ' t rm folder:no such folder!" wuRaw_input ("Press Enter to continue >") - aboutOs.mkdir ('pic') $ - forIinchRange (len (pngaddr)): - getpng (pngaddr[i], pngname[i]) - a #Html_code = chardet.detect (html) [' encoding '] + #Sys_code = sys.getfilesystemencoding () the #print "html is encoding by:", html_code - #print "system is encoding by:", sys_code $ #normal output Web page the #print Html.decode (html_code). encode (sys_code)
Configuration conditions: Make sure that Python2 is installed on your computer.
How to use: Create a new. py file, copy, save, and double-click to run the above Code.
Python crawler gets the SS QR code on the wtfx.tk