作者:LAMP小白 点击:1775 发布日期:2013-10-21 22:59:19 返回列表
获取网页源代码
import urllib
htmlobj = urllib.urlopen(url)
html = htmlobj.read()
下载文件
urllib.urlretrieve(url, filename)
#!/usr/bin/python #coding:utf8 import urllib import re htmlobj=urllib.urlopen('http://www.baidu.com') html=htmlobj.read() rule = r'<img src="([^">]+)"' imgarr=re.findall(rule, html) for imgurl in imgarr: print "img url is:%s" % imgurl
上一篇:ppython正则表达式 下一篇:快递查询API