selenium python 指定元素截图
2017-10-23 16:19
489 查看
1. 代码
# coding:utf-8 # coding:cp936 from selenium import webdriver from PIL import Image broswer = webdriver.Chrome() broswer.get("http://www.baidu.com") broswer.save_screenshot(r'E:\photo.png') baidu = broswer.find_element_by_id('su') left = baidu.location['x'] top = baidu.location['y'] elementWidth = baidu.location['x'] + baidu.size['width'] elementHeight = baidu.location['y'] + baidu.size['height'] picture = Image.open(r'E:\photo.png') picture = picture.crop((left, top, elementWidth, elementHeight)) picture.save(r'E:\photo2.png')
4000
2. 截图
截图 “百度一下”
参考:
1.利用 Python + Selenium 实现对页面的指定元素截图(可截长图元素)
相关文章推荐
- Python + Selenium 实现对页面的指定元素截图(可截长图元素)【转载】
- python selenium截取指定元素图片
- Python + selenium命名截图并保存到指定文件夹
- selenium截取具体元素图片(python版)
- 轻松自动化---selenium-webdriver(python) (三) 简单元素的定位
- Python+Selenium WebDriver API:浏览器及元素的常用函数及变量整理总结
- [Python爬虫] Selenium自动访问Firefox和Chrome并实现搜索截图
- (selenium+python)判断一个元素是否存在,if的错误用法
- [python爬虫] Selenium常见元素定位方法和操作的学习介绍
- Python+Selenium定位不到元素常见原因及解决办法(报:NoSuchElementException)
- Python中使用 Selenium 实现网页截图实例
- selenium+python使用js点击元素
- python selenium等待特定网页元素加载完毕
- Python+Selenium WebDriver API:浏览器及元素的常用函数及变量整理总结
- python+selenium 定位到元素,无法点击
- Python 对Twitter中指定话题的Tweet基本元素的频谱分析
- Selenium with Python 005 - 调用js操作页面元素
- Python+Selenium练习篇之6-利用class name定位元素
- Selenium(Python)等待元素出现