首页 技术 正文
技术 2022年11月17日
0 收藏 417 点赞 3,522 浏览 1068 个字
窗口命令pip install PIL(python3.6+selenium——2.53.1+pycharm)from PIL import Imagefrom selenium import webdriver
d=webdriver.Firefox()
d.get('http://www.baidu.com')
# 窗口最大化
d.maximize_window()
time.sleep(1)
# 进行全屏截图
d.get_screenshot_as_file('c:\mark666.png')
# 定位需要截图的元素位置
baidu=d.find_element('id','su')
# 获取element的顶点坐标
left=baidu.location['x']
top=baidu.location['y']
# 获取element的宽、高
elementwidth=baidu.location['x']+baidu.size['width']
elementheight=baidu.location['y']+baidu.size['height']
# 打开截图
p=Image.open('c:\mark666.png')
# 使用Image的crop函数,从截图中再次截取我们需要的区域,进行图片剪切
p=p.crop((left,top,elementwidth,elementheight))
# 保存我们需要的的图片
p.save(r'c:\mark6.png')

python抠图与pip install PIL报错

python抠图与pip install PIL报错

python抠图与pip install PIL报错

https://www.cnblogs.com/yuanzhoulvpi/p/9028713.html(导入pip install PIL报错参考)  可能是我进行了多次的安装和卸载,我在找着pip后输入pip install PIL报错:could not find a version that satisfies the requirement PIL    no matching distribution found for PIL找着个说要下载pillow,下载进行安装报错,然后就在DOS找着pip的目录下输入pip install wheel ,把下载的Pillow‑5.1.1‑cp36‑cp36m‑win_amd64.whl
拖到C:\Users\Administrator\AppData\Local\Programs\Python\Python36\Scripts 安装python目录的scripts文件夹里,最后在DoS窗口
找着pip的目录下输入pip install PIL就成功了。 (多次进行安装卸载selenium可能出现这个问题)

    					
相关推荐
python开发_常用的python模块及安装方法
adodb:我们领导推荐的数据库连接组件bsddb3:BerkeleyDB的连接组件Cheetah-1.0:我比较喜欢这个版本的cheeta…
日期:2022-11-24 点赞:878 阅读:9,088
Educational Codeforces Round 11 C. Hard Process 二分
C. Hard Process题目连接:http://www.codeforces.com/contest/660/problem/CDes…
日期:2022-11-24 点赞:807 阅读:5,564
下载Ubuntn 17.04 内核源代码
zengkefu@server1:/usr/src$ uname -aLinux server1 4.10.0-19-generic #21…
日期:2022-11-24 点赞:569 阅读:6,412
可用Active Desktop Calendar V7.86 注册码序列号
可用Active Desktop Calendar V7.86 注册码序列号Name: www.greendown.cn Code: &nb…
日期:2022-11-24 点赞:733 阅读:6,185
Android调用系统相机、自定义相机、处理大图片
Android调用系统相机和自定义相机实例本博文主要是介绍了android上使用相机进行拍照并显示的两种方式,并且由于涉及到要把拍到的照片显…
日期:2022-11-24 点赞:512 阅读:7,822
Struts的使用
一、Struts2的获取  Struts的官方网站为:http://struts.apache.org/  下载完Struts2的jar包,…
日期:2022-11-24 点赞:671 阅读:4,905