-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path使用python截图.py
34 lines (32 loc) · 1.15 KB
/
使用python截图.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
from selenium import webdriver
import time
from PIL import Image
driver = webdriver.Chrome()
driver.get('http://172.16.88.104/')
driver.maximize_window()
picture_url = driver.get_screenshot_as_file('a.png', )
time.sleep(2)
driver.find_element_by_xpath(
'/html/body/table/tbody/tr/td/table[3]/tbody/tr[1]/td[2]/form/table/tbody/tr[2]/td/table/tbody/tr[1]/td[2]/input').send_keys(
'')
driver.find_element_by_xpath(
'/html/body/table/tbody/tr/td/table[3]/tbody/tr[1]/td[2]/form/table/tbody/tr[2]/td/table/tbody/tr[2]/td[2]/input').send_keys(
'')
location = driver.find_element_by_id('vchart').location
size = driver.find_element_by_id('vchart').size
left = location['x']
top = location['y']
right = location['x'] + size['width']
bottom = location['y'] + size['height']
a = Image.open("a.png")
im = a.crop((left, top, right, bottom))
im.save('a.png')
Image._show(im)
yzm = input("请输入验证码:")
driver.find_element_by_xpath(
'/html/body/table/tbody/tr/td/table[3]/tbody/tr[1]/td[2]/form/table/tbody/tr[2]/td/table/tbody/tr[3]/td[2]/input').send_keys(
yzm)
driver.find_element_by_xpath('//*[@id="btnSure"]').click()
"""
公众号:城建417
"""