[Python爬虫] 之二十六:Selenium +phantomjs 利用 pyquery抓取智能电视网站图片信息
2017-06-23 11:33
1291 查看
一、介绍
本例子用Selenium +phantomjs爬取智能电视网站(http://www.tvhome.com/news/)的资讯信息,输入给定关键字抓取图片信息。给定关键字:数字;融合;电视
二、网站信息
三、数据抓取
针对上面的网站信息,来进行抓取1、首先抓取信息列表
抓取代码:Elements = doc('div[class="main_left fl"]').find('div[class="content"]').find('ul').find('li')
2、抓取图片
抓取代码:imgurl = element('a').find('img').attr('src');
self.down_picture(imgurl)
四、完整代码
def down_picture(self, imgurl): """ 下载图片到本地 :param imgurl: 图片url """ # http://img.tvhomeimg.com/uploads/2017/06/23/144910c41de4781ccfe9435e736ef72b.jpg if len(imgurl)>0: fileName = '' if imgurl.rfind('/')>0: fileName = imgurl[imgurl.rfind('/') + 1:] u = urllib.urlopen(imgurl) data = u.read() strpath = os.path.dirname(os.getcwd())+'\picture' with open(os.path.join(strpath, fileName), 'wb') as f: f.write(data)
相关文章推荐
- [Python爬虫] 之十八:Selenium +phantomjs 利用 pyquery抓取电视之家网数据
- [Python爬虫] 之二十二:Selenium +phantomjs 利用 pyquery抓取界面网站数据
- [Python爬虫] 之二十一:Selenium +phantomjs 利用 pyquery抓取36氪网站数据
- [Python爬虫] 之十六:Selenium +phantomjs 利用 pyquery抓取一点咨询数据
- [Python爬虫] 之二十七:Selenium +phantomjs 利用 pyquery抓取今日头条视频
- [Python爬虫] 之十七:Selenium +phantomjs 利用 pyquery抓取梅花网数据
- [Python爬虫] 之二十三:Selenium +phantomjs 利用 pyquery抓取智能电视网数据
- [Python爬虫] 之二十四:Selenium +phantomjs 利用 pyquery抓取中广互联网数据
- [Python爬虫] 之二十五:Selenium +phantomjs 利用 pyquery抓取今日头条网数据
- [Python爬虫] 之十九:Selenium +phantomjs 利用 pyquery抓取超级TV网数据
- 直播网站LiveTV Mining,爬虫抓取数据 python3+selenium+phantomjs
- <四>、python爬虫抓取购物网站商品信息--图片价格名称
- [Python爬虫] 之二十:Selenium +phantomjs 利用 pyquery通过搜狗搜索引擎数据
- Python爬虫使用Selenium+PhantomJS抓取Ajax和动态HTML内容
- python 实现网站图片抓取小爬虫
- [Python爬虫] 之十四:Selenium +phantomjs抓取媒介360数据
- python爬虫(17)爬出新高度_抓取微信公众号文章(selenium+phantomjs)(上)
- java爬虫实战(1):抓取信息门户网站中的图片及其他文件并保存至本地
- 利用python爬虫抓取OJ上做题信息(终结版)
- 利用NodeJS和PhantomJS抓取网站页面信息以及网站截图