标签:gre rac mpi log 抓取 read 程序 port 爬虫
#!/usr/bin/python
#抓取网页上的图片保存
import urllib
import urllib.request //python3版本将urllib2分成urllib.request和urllib.error
import re
def gethtml(url):
page = urllib.request.urlopen(url)
html = page.read()
return html
def getImages(html):
reg = r‘src="(.*?\.jpg)"‘
imgre = re.compile(reg)
imglist = re.findall(imgre,html.decode(‘utf-8‘))
x = 0
for i in imglist:
urllib.request.urlretrieve(i,r‘E:\python_practice\%s.jpg‘%(x))
x = x + 1
html=gethtml("http://www.u148.net/article/35256.html")
getImages(html)
该小程序是根据某个视频教学中写的,记录下,能跑成功一个小爬虫的程序,很是鸡冻。
标签:gre rac mpi log 抓取 read 程序 port 爬虫
原文地址:http://www.cnblogs.com/evablogs/p/7096355.html