0

奇怪的是,当我将 Web 驱动程序更改为 chrome 时,这个确切的代码可以工作。有谁知道为什么当我使用 Opera 而不是 chrome 时它不起作用?

def Start():
    # once opened it will fill in the confirm your age
    Day = Select(web.find_element_by_xpath('//*[@id="bday_day"]'))
    Day.select_by_index(2)
    Month = Select(web.find_element_by_xpath('//*[@id="bday_month"]'))
    Month.select_by_index(4)
    Month = Select(web.find_element_by_xpath('//*[@id="bday_year"]'))
    Month.select_by_index(24)
    Prov = Select(web.find_element_by_xpath('//*[@id="province"]'))
    Prov.select_by_index(5)
    Button = web.find_element_by_xpath('//*[@id="popup-subscribe"]/button')
    Button.click()

web = webdriver.Opera(executable_path=Folder + '\operadriver.exe')
web.get('https://www.tastyrewards.com/en-ca/contest/fritolaycontest/participate')
Start()

我使用 Opera 而不是 chrome 来使用 Opera 提供的免费 VPN,因为该网站的代码限制为 10 个,而且他们似乎会根据 IP 地址检查您是否达到 10 个。如果有办法从一开始就在 selenium 上使用 VPN,请告诉我,因为这样更容易

4

0 回答 0