def judith(SITE): driver = Edge(PATH) driver.get(SITE) #find the element by his name, it can be by its ID or CSS tho element = driver.find_element_by_name("objetos") element.clear() #insert the apropriate tracking code and then proceeds to the next page element.send_keys(CODE) element.send_keys(Keys.RETURN) #must implement total headless mode and print in terminal the state #it needs to go here #in this exact spot #save a screenshot of the tracking progress bc im lazy right now to implement a callback terminal function driver.save_screenshot('consulta.png') #if the code is wrong, it'll show this output assert "Sem bagulhos encontrados, mano." not in driver.page_source #close the program and the browser window. BEWARE driver.close()
driver.find_elements_by_xpath( '//*[@id="app"]/div/div[2]/div[2]/div/div[1]/div/div/div/div/section/div/div[3]/div[' + str(loc(mydate)) + ']/div')[0].click() # 打卡成功 temp = clock_in_successfully() print(temp) today_log.append(temp) successful += 1 # 打卡完毕 print(your_name, '第' + str(t + 1) + '次打卡成功') if if_shot == "是": driver.save_screenshot(screenshot_name) sleep(0.5) send_main() # 退出 driver.quit() break except: sleep(2) if_ci = if_clock_in_today() if if_ci == 1: successful += 1 print(your_name + "今日已打卡!") driver.quit()
# get opportunity atlas driver.get("https://opportunityatlas.org/") time.sleep(10) # click on get started atlas get_started = driver.find_element_by_xpath( "/html/body/div[3]/div[2]/div[1]/p[5]/button") get_started.click() # find element element = driver.find_element_by_id('introductionDialog') driver.execute_script( """ var element = arguments[0]; element.parentNode.removeChild(element); """, element) search_box = driver.find_element_by_xpath( '/html/body/div[2]/div[1]/div[2]/div[3]/div[2]/input') search_box.clear() search_box.send_keys(tract_id) time.sleep(2) search_box.send_keys(Keys.ENTER) time.sleep(10) driver.save_screenshot('test.png') #with io.BytesIO(driver.get_screenshot_as_png()) as f: # f.write('./test.png') driver.close()
# options.add_argument("disable-gpu") options.add_experimental_option("excludeSwitches", ['enable-automation', 'enable-logging']) # options.add_argument('-kiosk') #全屏打开 wd = Edge(options = options) wd.get('https://kyfw.12306.cn/otn/resources/login.html') time.sleep(1) #全屏 wd.maximize_window() #点击账户登录 wd.find_element_by_xpath('/html/body/div[2]/div[2]/ul/li[2]/a').click() time.sleep(1) #screenshot wd.save_screenshot('./10.screenshot.png') code_img_ele = wd.find_element_by_xpath('/html/body/div[2]/div[2]/div[1]/div[2]/div[3]/div/div[4]/img') #裁剪截图 location = code_img_ele.location print('location:' ,location) size = code_img_ele.size print('size:',size) rangle = ( location['x'],location['y'],location['x']+size['width'],location['y']+size['height']) i = Image.open('./10.screenshot.png') code_img_name = './10.CAPTCHA.png' #crop根据指定区域进行裁剪 frame = i.crop(rangle) frame.save(code_img_name)