1 #-*-coding:utf-8-*-2 __author__="Carry"3 ImportUrllib4 ImportUrllib25 fromBs4ImportBeautifulSoup6 7 8URL ='http://www.dbmeinv.com/?pager_offset=1'9x = 1Ten defCrawl (URL): Oneheaders = {'user-agent':'mozilla/5.0 (Windows NT 6.1; WOW64) applewebkit/537.36 (khtml, like Gecko) chrome/50.0.2661.102 safari/537.36'} Areq = Urllib2. Request (url,headers=headers) -page = Urllib2.urlopen (req,timeout=20) -Contents =Page.read () the #Print (Contents.decode (' Utf-8 ')) -Soup = beautifulsoup (contents,'Html.parser') -My_girl = Soup.find_all ('img') - #Print My_girl + forGirlinchMy_girl: -link = girl.get ('src') + PrintLink A Globalx atUrllib.urlretrieve (Link,'image\%s.jpg'%x) - Print("Downloading page%s"%x) -X +=1 - - forPageinchRange (1,20): -URL ='http://www.dbmeinv.com/?pager_offset=%d'%page in Crawl (URL) - Print("Picture Download Complete")
One of the python crawlers---------watercress sister figure