from selenium import webdriver
from PIL import Image
from time import sleepbrowser = webdriver.Edge()
browser.maximize_window()
browser.get('https://kyfw.12306.cn/otn/resources/login.html')
sleep(1)
browser.execute_script('document.querySelector("body > div.login-panel > div.login-box > ul > li.login-hd-account > a").click()')
sleep(1)
browser.save_screenshot('./img.png')
sleep(2)
img_ele = browser.find_element_by_xpath('//*[@id="J-loginImgArea"]')
img_location = img_ele.location
img_size = img_ele.size
x1 = int(img_location['x'])
y1 = int(img_location['y'])
x2 = x1 + int(img_size['width'])
y2 = y1 + int(img_size['height'])
box = (x1,y1,x2,y2)
print(box)
img = Image.open('./img.png')
img.crop(box).save('./img1.png')
browser.quit()
本文来自互联网用户投稿,文章观点仅代表作者本人,不代表本站立场,不承担相关法律责任。如若转载,请注明出处。 如若内容造成侵权/违法违规/事实不符,请点击【内容举报】进行投诉反馈!