I'm trying to make a bot for https://www.phonehouse.nl/verlengchecker . But when I use Chrome it gets detected. When I use Firefox it only opens the page and doesn't do anything. I tried it on Arch linux and Windows result is the same.
from selenium import webdriver
from time import sleep
capabilities = {
'browserName': 'chrome',
'chromeOptions': {
'useAutomationExtension': False,
'forceDevToolsScreenshot': True,
'args': ['--start-maximized', '--disable-infobars']
}
}
driver = webdriver.Chrome(capabilities=capabilities)
def control(provider, number, day, month, year, post, email, street):
driver.get("https://www.phonehouse.nl/verlengchecker")
sleep(1)
driver.find_element_by_xpath("//span[@id='businessSelectBoxIt']").send_keys(provider) #provider
driver.find_element_by_xpath("//input[@name='msisdn']").send_keys(number) #number
Your analysis was in the right direction. Selenium driven ChromeDriver initiated google-chrome Browsing Context can easily get detected by the recaptcha .
If you access the DOM Tree you will find the existance of the recaptcha .
Recaptcha can easily detect WebDriver initiated Browsing Context .
You can find a detailed discussion in How does recaptcha 3 know I'm using selenium/chromedriver?
However there are some generic ways to avoid detection and you can find a detailed discussion in How to bypass Google captcha with Selenium and Python?
You can find a relevant detailed discussion in:
Well, the "provider" space isn't an input so you can't use send_keys
,
But you can use this for the number:
from selenium import webdriver
from time import sleep
driver = webdriver.Firefox()
def control(number):
driver.get("https://www.phonehouse.nl/verlengchecker")
sleep(1)
driver.find_element_by_xpath('//*[@id="msisdn"]').send_keys(number)
control("000")
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.