"" PATH = "C:\Program Files (x86)\chromedriver.exe"
driver = webdriver.Chrome(PATH)
mylink = 'https://www.oddschecker.com'
driver.get(mylink) ""
Trying to navigate through oddschecker website using selenium in python with chrome webdriver but an add comes up (see image)
Is there a line of code I can use to get rid of the ad and access the site without having to click on the cross in top right corner manually?
Any help would be greatly appreciated.
Thanks
CodePudding user response:
This would help you in closing the ad.
driver.get('https://www.oddschecker.com')
time.sleep(4)
driver.find_element(By.XPATH, "//*[@aria-label='Close Offers Modal']").click()
P.S. I wrote in python. If you are writing in some other language, you may transform this line per the syntax of your language.
CodePudding user response:
You can integrate AdBlocker extension within you chrome driver just like this:
from selenium import webdriver
from selenium.webdriver.chrome.options import Options
chrome_options = Options()
chrome_options.add_argument('load-extension=' EXTENSION_PATH)
driver = webdriver.Chrome(DRIVER,chrome_options=chrome_options)
driver.create_options()