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 35 36 37 38 39 40 41 42 43
| from selenium.webdriver import Chrome from selenium.webdriver import ActionChains from selenium.webdriver.chrome.options import Options from chaojiying import Chaojiying_Client import time
chaojiying = Chaojiying_Client('18614075987', '6035945', '914467')
option = Options() option.add_argument('--disable-blink-features=AutomationControlled')
web = Chrome(options=option) web.get("https://kyfw.12306.cn/otn/resources/login.html") time.sleep(2) web.find_element_by_xpath('/html/body/div[2]/div[2]/ul/li[2]/a').click() time.sleep(3)
verify_img_element = web.find_element_by_xpath('//*[@id="J-loginImg"]')
dic = chaojiying.PostPic(verify_img_element.screenshot_as_png, 9004) result = dic['pic_str'] rs_list = result.split("|") for rs in rs_list: p_temp = rs.split(",") x = int(p_temp[0]) y = int(p_temp[1]) ActionChains(web).move_to_element_with_offset(verify_img_element, x, y).click().perform()
web.find_element_by_xpath('//*[@id="J-userName"]').send_keys("userName") web.find_element_by_xpath('//*[@id="J-password"]').send_keys("password")
web.find_element_by_xpath('//*[@id="J-login"]').click() time.sleep(5)
btn = web.find_element_by_xpath('//*[@id="nc_1_n1z"]') ActionChains(web).drag_and_drop_by_offset(btn, 300, 0).perform()
|