爬虫

来源:互联网 发布:wap站长之家源码 编辑:程序博客网 时间:2024/05/22 06:50
#!/usr/bin/env python#coding=utf-8import reimport urllibdef getHtml(url):    page = urllib.urlopen(url)    html = page.read()    return htmldef getImg(html):    reg = r'src="(.+\.png)"'    imgre = re.compile(reg)    imglist = re.findall(imgre,html)    x = 1    for imgurl in imglist:        urllib.urlretrieve(imgurl,'%s.png' % x)        x += 1html = getHtml("http://172.25.254.100")print getImg(html)
0 0