I've been trying to use selenium in order to google a list of airports to be able to get information from a website that I use tab to get to. It works every single time when the ads don't appear on the webpage. I've spent a bit of time trying to solve this but nothing is seeming to work. This is a fraction of my code for you guys to understand what I'm trying to do:
driver = webdriver.Chrome()
driver.get("https://www.google.com")
a = driver.find_element_by_css_selector(".gLFyf")
a.clear()
a.send_keys(f'site:airnav.com/airport airnav {a[i]} {b[i]}')
print(f'airnav {a[i]} {b[i]}')
a.send_keys(Keys.RETURN)
actions = ActionChains(driver)
actions1 = actions.send_keys(Keys.TAB*19)
actions1.perform()
time.sleep(3)
actions = ActionChains(driver)
actions2 = actions.send_keys(Keys.ENTER)
actions2.perform()
act = driver.current_url
driver = webdriver.Chrome()
driver.get(f'https://web.archive.org/web/2015/{act}')
time.sleep(3)
The a and b are lists, I'm googling every single element from those lists and getting to the same website. The only thing that ever stops the TAB method from working are these ads that keep appearing every second time I try this.