python爬虫 -- 截图网页中的图片(先Mark下,待改善)
2018-01-19 16:35
393 查看
# -*- coding: utf-8 -*- from selenium import webdriver from PIL import Image if __name__ == '__main__': codePrefix = u'https://kyfw.12306.cn/passport/captcha/captcha-image' wbe = webdriver.PhantomJS('/usr/bin/phantomjs') wbe.get("https://kyfw.12306.cn/otn/login/init") # 此处有问题,还待解决,学习爬虫中,,,,,, #element = wbe.find_element_by_xpath('//*[@id="loginForm"]/div/ul[1]/li[4]/div/div/div[2]/img') element = wbe.find_element_by_xpath('//*[contains(@class_name="touclick-image")]') left = element.location['x'] top = element.location['y'] right = element.location['x'] + element.size['width'] bottom = element.location['y'] + element.size['height'] im = Image.open(r'登录页.png')# 全页面截屏 im = im.crop((left, top, right, bottom)) im.save('验证码.png') r''' Message: 'phantomjs' executable needs to be in PATH. geckodriver 要自行下载 phantomjs 自行下载 ''' def get_image(): pass
相关文章推荐
- python抓取网页图片 python爬虫实例
- Python3.x爬虫下载网页图片的实例讲解
- python爬虫 -- 抓取网页中链接的静态图片
- python抓取网页图片示例(python爬虫)
- python爬虫之抓取网页中的图片到本地
- Python爬虫学习笔记二:百度贴吧网页图片抓取
- Python 爬虫5——爬取并下载网页指定规格的图片
- Python3.x爬虫教程:爬网页、爬图片、自动登录
- Python3简单爬虫抓取网页图片
- Python爬虫urllib2笔记(三)之使用正则表达式提取百度贴吧网页中的楼主发的图片
- python爬虫(1)下载任意网页图片
- [python][爬虫]从网页中下载图片
- python 网页爬虫+保存图片+多线程+网络代理
- python3 爬虫--网页图片爬取
- Python3批量爬取网页图片(小爬虫)
- python3.3网页图片爬虫
- Python爬虫实现抓取网页图片
- python 爬虫 获取网页中的图片
- 第一个python程序,小爬虫--抓取网页图片
- 【Python】python3实现网页爬虫下载图片