Python简单爬虫
2014-10-26 17:42
246 查看
简单Python爬虫,获得网页上的照片
#coding=utf-8
import urllib
import re
def getHtml(url):
page = urllib.urlopen(url)
html = page.read()
return html
def getImg(html):
reg = r'src="(.+?\.jpg)" pic_ext'
imgre = re.compile(reg)
imglist = re.findall(imgre, html)
return imglist
// 网站地址
url = "http://tieba.baidu.com/p/3368048910?pn=2"
html = getHtml(url)
listimg = getImg(html)
x = 0
for imgAddress in listimg:
print imgAddress
urllib.urlretrieve(imgAddress, 'image%s.jpg' % x)
x+=1
#coding=utf-8
import urllib
import re
def getHtml(url):
page = urllib.urlopen(url)
html = page.read()
return html
def getImg(html):
reg = r'src="(.+?\.jpg)" pic_ext'
imgre = re.compile(reg)
imglist = re.findall(imgre, html)
return imglist
// 网站地址
url = "http://tieba.baidu.com/p/3368048910?pn=2"
html = getHtml(url)
listimg = getImg(html)
x = 0
for imgAddress in listimg:
print imgAddress
urllib.urlretrieve(imgAddress, 'image%s.jpg' % x)
x+=1
相关文章推荐
- python写简单爬虫的五种方法
- Python与简单网络爬虫的编写
- 用 python 做简单的网页爬虫程序
- python实现简单爬虫功能
- python-简单爬虫
- python 简单的网络爬虫 + html 正文抽取
- [Python]网络爬虫(六):一个简单的百度贴吧的小爬虫
- 用 python 做简单的网页爬虫程序
- python简单爬虫(上):urllib,urllib2与cookielib三个模块
- python实现简单爬虫功能
- 一个简单的python爬虫程序
- 【转】用python写简单爬虫
- python基础学习-7(简单爬虫)
- 一段简单的 Python 爬虫程序
- python写简单爬虫的五种方法 (转)
- Python简单两步实现天气爬虫采集器
- [Python]第八课笔记 简单代理爬虫
- python写简单爬虫的五种方法 (转)
- [Python]网络爬虫(六):一个简单的百度贴吧的小爬虫
- Python3.x学习笔记[1]:2种简单爬虫获取京东价格