- import urllib
- import string
- import re
- def gethtml(url):
- page=urllib.urlopen(url)
- html=page.read()
- return html
- def getPic(html):
- imgre=re.compile(r'src=".+?\.jpg" data-big-img')
- imglist=re.findall(imgre,html)
- print imglist
- x=0
- for imgurl in imglist:
- #src="http://www.xcxx.com/lld.jpg"'
- imgurl=imgurl.replace('src="','')
- imgurl=imgurl.replace('" data-big-img','')
- urllib.urlretrieve(imgurl,'%s.jpg' %x)
- x+=1
- html=getHtml("http://www.xcxx.com/")
来源: http://www.phpxs.com/code/1004900/