python中使用网络爬虫下载图片
2014-03-24 16:07
781 查看
import re
import urllib
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 = imgre.findall(html)
x = 0
for imgurl in imglist:
urllib.urlretrieve(imgurl,'%s.jpg' % x)
x = x + 1
html = getHtml("http://tieba.baidu.com/p/2460150866")
getImg(html)
import urllib
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 = imgre.findall(html)
x = 0
for imgurl in imglist:
urllib.urlretrieve(imgurl,'%s.jpg' % x)
x = x + 1
html = getHtml("http://tieba.baidu.com/p/2460150866")
getImg(html)
相关文章推荐
- Python3网络爬虫:Scrapy入门之使用ImagesPipline下载图片
- python 网页爬虫,下载网络图片
- python 网络爬虫爬取落网 期刊内容 下载图片 音乐
- 使用简易Python爬虫下载百度贴吧图片
- python3.6 urllib.request库实现简单的网络爬虫、下载图片
- 使用Python编写简单网络爬虫抓取视频下载资源
- python 3.x网络爬虫 下载图片
- 使用Python编写简单网络爬虫抓取视频下载资源
- mac os平台使用python爬虫自动下载巨潮网络文件
- 使用python进行爬虫下载指定网站的图片
- 使用Python编写简单网络爬虫抓取视频下载资源
- python 使用 urllib.urlretrieve()下载网络图片,在本地打开提示文件损坏无法打开
- python网络爬虫之使用scrapy下载文件
- 使用Python编写简单网络爬虫抓取视频下载资源
- python网络爬虫之使用scrapy爬取图片
- python批量下载色影无忌和蜂鸟的图片 爬虫小应用
- 手把手教你写基于C++ Winsock的图片下载的网络爬虫
- Afinal加载网络图片及下载文件使用方法
- python使用re, os, httplib, urllib批量下载网页上的图片
- Python 爬虫学习 网页图片下载