def lambda_handler(*args, **kwargs): driver = WebDriverWrapper() driver.get_url('http://example.com') example_text = driver.get_inner_html('(//div//h1)[1]') driver.close() return example_text
def lambda_handler(*args, **kwargs): driver = WebDriverWrapper() receiptnumber = os.getenv("RECEIPTNUMBER") driver.get_url('https://egov.uscis.gov/casestatus/landing.do') driver.set_input_value( '/html/body/div[2]/form/div/div[1]/div/div[1]/fieldset/div[1]/div[4]/input', receiptnumber) driver.click( '/html/body/div[2]/form/div/div[1]/div/div[1]/fieldset/div[2]/div[2]/input' ) example_text = driver.get_inner_html('(//div//h1)[1]') driver.close() return example_text
def lambda_handler(*args, **kwargs): driver = WebDriverWrapper() driver.get_url('https://www.google.es/') driver.set_input_value('//input[@name="q"]', '21 buttons') button = driver.find("(//input[@name='btnK'])[2]") button.send_keys(Keys.TAB) driver.click('//input[@name="btnK"]') first_google_result_title = driver.get_inner_html( '(//div[@class="rc"]//a)[1]') print("--------------------------") print(first_google_result_title) print("--------------------------") driver.close()
def lambda_handler(*args, **kwargs): driver = WebDriverWrapper() driver.get_url('https://www.myprotein.com/nutrition/protein.list') # driver.set_input_value('//input[@name="q"]', '21 buttons') # button = driver.find("(//input[@name='btnK'])[2]") # button.send_keys(Keys.TAB) # driver.click('//input[@name="btnK"]') time.sleep(2) offers_html = driver.get_inner_html( "//*[@class='stripBanner']//*[@class='stripBanner_text']//p") print("--------------------------") print('Banner element:', offers_html) voucher_code_reg = re.search(r"CODE\:(.*)", offers_html) # print("Code (match):", voucher_code_reg) print("Code (regex):", voucher_code_reg.group(0)) voucher_code = voucher_code_reg.group(1).strip() print("Code:", voucher_code) voucher_text_reg = re.search(r"(.*)\|", offers_html) print("Code desc (regex):", voucher_text_reg.group(0)) voucher_desc = re.sub('<[^<]+?>', ' ', voucher_text_reg.group(1).strip()) print("Code description:", voucher_desc) print("--------------------------") # first_google_result_title = driver.get_inner_html( # '(//div[@class="rc"]//a)[1]') # print("--------------------------") # print(first_google_result_title) # print("--------------------------") driver.close() return {'message': f"Code: {voucher_code}, Description: {voucher_desc}"}
def lambda_handler(*args, **kwargs): driver = WebDriverWrapper() driver.get_url('https://www.google.es/') driver.set_input_value('//input[@id="lst-ib"]', '21 buttons') driver.click('//center//img[@alt="Google"]') time.sleep(0.5) driver.click('//input[@name="btnK"]') time.sleep(0.5) first_google_result_title = driver.get_inner_html( '(//div[@class="rc"]//a)[1]') print("--------------------------") print(first_google_result_title) print("--------------------------") driver.close()
def lambda_handler(*args, **kwargs): driver = WebDriverWrapper() driver.get_url('https://www.amazon.com/') html = driver.get_inner_html('//*[@id="nav-your-amazon"]') # driver.click('//center//img[@alt="Google"]') # time.sleep(0.5) # # driver.click('//input[@name="btnK"]') # time.sleep(0.5) # # first_google_result_title = driver.get_inner_html('(//div[@class="rc"]//a)[1]') print("--------------------------") # print(first_google_result_title) print(html) print("--------------------------") driver.close() return 0