python爬虫——BeautifulSoup 抓取图片
2017-08-22 11:25
459 查看
python 利用BeautifulSoup 抓取图片
# -*- coding: utf-8 -*- """ """ import urllib from bs4 import BeautifulSoup #beautifulsoup方法,第三方库的方法,爬找网页 ## 下载网页 def get_content(url): ''' @url:需要下载的网址 下载网址 ''' html = urllib.request.urlopen(url) content = html.read().decode('utf-8')#转码 html.close()#记得要将打开的网页关闭,否则会出现意想不到的问题 # print (type(content)) return content def get_image(info): ''' 利用Soup第三方库实现抓取 ''' soup = BeautifulSoup(info,'html.parser')#设置解析器为“lxml” all_image = soup.find_all('img',class_ = "BDE_Image") x=1 for image in all_image: print(all_image) urllib.request.urlretrieve(image['src'],"E:\\WORK\\py\\TensorFlow\\爬取树叶图片\\BS-Soup\\%s.jpg"%(x)) x+=1 url = "https://tieba.baidu.com/p/5114003992" info = get_content(url) #print (info) get_image(info)
相关文章推荐
- python爬虫抓取图片到本地
- 编写Python爬虫抓取暴走漫画上gif图片的实例分享
- 【python】100行代码python爬虫程序,抓取网站图片存储本地(附:中文链接解决)
- 用Python BeautifulSoup写的一份多线程图片抓取的脚本
- Python爬虫之网页图片抓取的方法
- Python爬虫之一 PySpider 抓取淘宝MM的个人信息和图片
- Python之BeautifulSoup学习之一 粗略抓取网页图片连接地址
- <四>、python爬虫抓取购物网站商品信息--图片价格名称
- 用python实现的一个抓取图片的爬虫
- Python爬虫抓取网页图片
- Python爬虫实现抓取京东店铺信息及下载图片功能示例
- [python]利用BeautifulSoup进行简单图片抓取
- python3用BeautifulSoup抓取图片地址
- python爬虫之抓取网页中的图片到本地
- python抓取网页图片示例(python爬虫)
- Python 爬虫 抓取百度图片资源 压缩图片
- Python爬虫抓取网页图片
- Python爬虫抓取虎扑论坛帖子图片
- Python爬虫实战(1)——百度贴吧抓取帖子并保存内容和图片
- python爬虫 -- 抓取网页中链接的静态图片