Skip to content

Commit 0331284

Browse files
committed
粉丝投稿 代码提交
1 parent e87dc02 commit 0331284

File tree

2 files changed

+55
-0
lines changed

2 files changed

+55
-0
lines changed

fans/README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ Python技术 公众号文章代码库
1414

1515
[echarts的可视化](https://github.com/JustDoPython/python-examples/tree/master/fans/shift):echarts的可视化
1616

17+
[PyAutoGUI,轻松搞定图片上传!](https://github.com/JustDoPython/python-examples/tree/master/fans/imgupload):PyAutoGUI,轻松搞定图片上传!
1718

1819

1920

fans/imgupload/imgupload.py

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
import time
2+
import pyautogui
3+
4+
def auto_upload(x,y,file_path):
5+
# 点击”选择文件“按钮
6+
pyautogui.click(307, 227)
7+
time.sleep(2.5)
8+
9+
# 弹出对话框后,点击路径那一栏,目的是为下一步粘贴路径
10+
pyautogui.click(993, 332)
11+
time.sleep(1.5)
12+
13+
# 键入图片路径
14+
pyautogui.typewrite(file_path)
15+
# 按回车键
16+
pyautogui.hotkey('enter')
17+
time.sleep(1)
18+
19+
# 双击图片
20+
pyautogui.doubleClick(x,y)
21+
# 等文件出现
22+
time.sleep(6)
23+
24+
# 点击“上传”按钮
25+
pyautogui.click(304, 278)
26+
#等几秒传完
27+
if x == 847:
28+
#847是第一张图片的x坐标,因为我上传的第一张是gif动图,文件大,上传多等几秒
29+
time.sleep(11)
30+
else:
31+
time.sleep(2.5)
32+
33+
# 点击“copy”按钮
34+
pyautogui.click(297, 545)
35+
time.sleep(1)
36+
37+
# 点击浏览器的地址栏
38+
pyautogui.click(410, 66)
39+
40+
# 模拟键盘点击ctrl+v,然后按回车键
41+
pyautogui.hotkey('ctrl','v')
42+
time.sleep(0.5)
43+
pyautogui.hotkey('enter')
44+
45+
#欣赏美女3秒
46+
time.sleep(3)
47+
48+
# 点击浏览器的返回按钮
49+
pyautogui.click(32, 67)
50+
time.sleep(2)
51+
52+
#文件的x,y坐标
53+
file_list = [(847, 489),(965, 490),(1136, 493),(1271, 504),(1391, 498)]
54+
[ auto_upload(f[0],f[1],'C:/Users/0717/Pictures/blog/upload') for f in file_list]

0 commit comments

Comments
 (0)