In the bar when you see the bar paste inside the beautiful picture, or have beautiful sister paper pictures, is not want to save it?
But some pages of pictures more, one by one to save more trouble.
Recently learning Python, so using Python to crawl the content of the Web is more convenient:
So I tried it for a bit.
------Code-------
#coding =utf-8import re import urllib //Import Module def gethtml (URL): //Custom function to get Web page content page=urllib.urlopen (URL) html=page.read () return htmldef getimg (HTML): //Custom Function, Get the content you need reg=r ' src= ' (. +?\.jpg) " pic_ext ' //regular expressions, grab image links, see html.jpg Imgre=re.compile (REG) //compiles the regular expression into a regular expression object, To improve the crawl efficiency imglist=re.findall (imgre,html) //get all the matching regular expression objects in the HTML x=1 for imgurl in imglist: //loops through the entire list of links urllib.urlretrieve (Imgurl, ' f:\\myimg\\ Myimage\\ %s.jpg ' % x) //save picture to target folder x=x+1 html=gethtml (" //to get the page link print getimg (HTML)-----------------------------------diagram: If you have any questions, please download the graphic image to view my Cheetah browser.
This article is from the "Kuing Home pages" blog, so be sure to keep this source http://kuing.blog.51cto.com/9635522/1709672
Python crawler for crawling web images