Posted in Python onFebruary 28, 2014
#coding:utf8 import re import urllib def getHTML(url): page = urllib.urlopen(url) html = page.read() return html def getImg(html,imgType): reg = r'src="(.*?\.+'+imgType+'!slider)" ' imgre = re.compile(reg) imgList = re.findall(imgre, html) x=0 for imgurl in imgList: print imgurl urllib.urlretrieve(imgurl, '%s.%s' % (x, imgType)) x =x+1 html= getHTML("https://3water.com") getImg(html,'jpg')
python抓取网页中的图片示例
声明:登载此文出于传递更多信息之目的,并不意味着赞同其观点或证实其描述。
Reply on: @reply_date@
@reply_contents@