The ChromeDriver detects when the Chrome browser is launched

When attempting to use selenium chromedriver in Python for the website www.mouser.co.uk, it is immediately flagged as a bot. Does anyone have an explanation for this? Below is the code I am utilizing:

https://i.stack.imgur.com/g3uLP.png

options = Options()
options.add_argument("--start-maximized")
browser = webdriver.Chrome('chromedriver.exe',chrome_options=options)
wait = WebDriverWait(browser, 30)
browser.get('https://www.mouser.co.uk')

Answer ā„–1

My attempts to visit the website https://www.mouser.co.uk/ using specific chrome.options resulted in detection and redirection to a page displaying Pardon Our Interruption.

  • Code snippet:

    from selenium import webdriver
    from selenium.webdriver.chrome.options import Options
    from selenium.webdriver.common.by import By
    from selenium.webdriver.support.ui import WebDriverWait
    from selenium.webdriver.support import expected_conditions as EC
    
    options = Options()
    options.add_argument("start-maximized")
    options.add_argument("disable-infobars")
    options.add_argument("--disable-extensions")
    driver = webdriver.Chrome(chrome_options=options, executable_path=r'C:\Utility\BrowserDrivers\chromedriver.exe')
    driver.get("https://www.mouser.co.uk")
    myElement = WebDriverWait(driver, 30).until(EC.element_to_be_clickable((By.XPATH, "//a[@id='1_lnkLeftFlag']")))
    driver.execute_script("arguments[0].click();", myElement)
    

Upon examining the Pardon Our Interruption page, it was observed that the <body> tag contains:

  • The class attribute dist-GlobalHeader
  • The class attribute dist-PageWrap

This suggests that the website is protected by the Distil Networks Bot Management service provider, which detects navigation by ChromeDriver and subsequently blocks it.


Distil

According to an article on Forbes:

Distil safeguards sites from automated content scraping bots by observing site behavior and identifying patterns unique to scrapers. When a malicious bot is identified on one site, Distil creates a blacklisted behavioral profile that is deployed to all its customers. Similar to a bot firewall, Distil detects patterns and responds accordingly.

Futhermore,

"One pattern with Selenium was automating the theft of Web content"
, stated Distil CEO Rami Essaid.
"Even though they can create new bots, we figured out a way to identify Selenium as the tool they're using, so we're blocking Selenium regardless of how many iterations they make. We're now doing the same with Python and various other technologies. Once we observe a pattern emerging from a certain type of bot, we analyze the technology being used and flag it as malicious".


Reference

You may find additional insights in the following discussions:

  • Distil detects WebDriver driven Chrome Browsing Context
  • Selenium webdriver: Modifying navigator.webdriver flag to prevent selenium detection
  • Akamai Bot Manager detects WebDriver driven Chrome Browsing Context

Answer ā„–2

After trying all the recommendations provided here without success, I finally found a solution that worked for me:

https://github.com/ultrafunkamsterdam/undetected-chromedriver

I used this module to bypass bot detection on a website. Despite attempting various methods suggested in previous responses, only this one proved effective. The instructions for using the module are clear and can be found on the GitHub repository itself.

On a side note, it appears that previous versions of this post have been deleted by moderators multiple times, which I believe was unjustified. Hopefully, this revised version will remain visible. Best of luck to others facing similar challenges.

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

The Django application is failing to interact with the AJAX autocomplete functionality

After typing the term "bi" into the search bar, I expected to see a username starting with those initials displayed in a dropdown list. However, nothing is showing up. Here are the codes I have used: search.html <html> <div class="ui-widget"> ...

Why is my Python string formatted differently without using repr or str functions?

Within my codebase, I created an enumeration called ResourceType. This enum inherits from both namedtuple and Enum, without any overriding of the __str__ or __repr__ methods. Strangely, when I try to format an instance of this enum, I only see the raw valu ...

What is the best way to swap out a specific text in a contenteditable div?

I am currently working on a project where I need to replace chapter titles in a contenteditable div tag using Python and Selenium WebDriver. The process involves searching for the chapter title, which is usually located at the first line, then replacing it ...

Tips for extracting text from a selenium webelement icon that displays hovertext

Let's use Amazon as an example. Suppose we want to extract the star rating for a product. When hovering over the stars, we see a text element that says "4.0 out of 5 stars" and upon inspecting the code, we find: <span class="a-icon-alt">4.0 ou ...

Mastering the art of window switching with WinAppDriver Java

Iā€™m currently diving into the world of Windows automation with WinAppDriver. Our application is built using Chromium browser, but since the main app we need to access is Windows-based, we are using WinAppDriver for automation. Whenever I click on the O ...

Troubleshooting: Issues with Firefox WebDriver profile functionality following IEDriverServer configuration

After using webdriver.Firefox() for my test cases, I decided to test on IE. I successfully downloaded IEDriverServer, added it to my PATH, and ran the IE test case without any issues. However, when I switched back to Firefox and attempted to run the same t ...

The on_message function will check if a message is received, only within the on_bot command

Brand new to posting and looking for guidance on upgrading my Discord Bot! Currently, the Bot can successfully execute the !decklist command. However, when I encounter a situation where there are no message attachments and attempt to run the !boh command, ...

An effective way to divide a string in Python with no separator involved

How can I effectively use some_string.split('') in Python? The current syntax is causing an error: a = '1111' a.split('') ValueError: empty separator My goal is to achieve the following result: ['1', '1&apos ...

What is the process of utilizing a Radiobutton to assign a specific integer value to a variable?

To incorporate a variable for "BAI_var1" in a multiple-choice command line software, I utilized the following line of code: BAI_var1 = input ("Please enter 0 for not at all, 1 for somewhat, 2 for moderately or 3 for a lot:") Displayed below is my Graphic ...

Running a basic Selenium automation test using FireFox on Mac OS and Eclipse: A step-by-step guide

I'm currently facing an issue while trying to run automation tests using Selenium in Firefox by adding the Geckodriver to my Java project. Despite downloading and adding various jar files, I keep encountering the same error message in the Eclipse cons ...

Serializer for ManyToManyField

I've been attempting to set up a response for ManyToManyField. It's strange that when I switch the model to ManyToManyField, the expected output doesn't show up as anticipated, although it works fine with ForeignKey. ProductSerializer class ...

Having trouble with the Google Places API integration using Python

Hey there! I'm currently experimenting with the Google Places API in a rather unique way - trying to fetch a list of all McDonald's locations in Germany. I know, it's a bit unusual! Below is the code I've put together for this task (the ...

Efficient method for transforming a four-dimensional list into a pandas dataframe

I have been working on converting a 4-dimensional list into a pandas dataframe. My current solution involves using a triple nested for loop, but I suspect there might be a more efficient way to achieve this. Below is the code snippet I am currently using: ...

Resampling in Python with pandas can quickly and easily convert monthly data into weekly intervals

Attempting to establish ranges for monthly and weekly stock data. The current code successfully calculates the high values on a monthly basis, but encounters issues with weekly data resulting in NaN values when trying to create a new column in the datafr ...

Having trouble obtaining the XPath in Python using Selenium

I am currently trying to locate the xpath for this particular HTML structure. <div class="col-xs-6 pg-desc-section"> <p class="boldText">Jewelry</p> <p data-hostname="nikki stanzione" data- ...

gatsby-plugin-image compatible with macOS Catalina

Upon further investigation, I discovered that Gatsby 5 now requires node version 18 or higher. Additionally, to utilize the gatsby-plugin-image, it seems that upgrading my macOS (from OSX 10.15 Catalina to Big Sur or higher) is necessary. As I attempted ...

How can software design patterns be utilized for implementing branching logic?

Currently in my test automation, I've implemented a basic version of the Page Object Pattern. However, I've noticed that there is redundancy in my code. Within a single class, I have multiple methods that essentially perform the same task but re ...

Capturing screenshots of error pages using Selenium WebDriver

I am currently facing an issue where I encounter the same error page upon clicking various buttons on my website. To track this issue, I want to capture screenshots of this error page each time it appears, along with identifying which specific link trigger ...

Troubleshooting Selenium in Python: Dealing with Empty Results Across Different Methods

I have searched for a solution to my issue, but none of the existing answers seem to work. My struggle lies in trying to locate an element within this specific page: driver = webdriver.Chrome() driver.set_window_size(0, 0) driver.set_window_position(0, 0 ...

The headless mode of Python Selenium with Chrome driver is not functioning properly

I attempted to create a bot that automates purchases on Amazon's website, and I succeeded. However, when I tried to optimize the bot for speed by making the Chrome driver headless, it stopped functioning properly (specifically, it kept going to a NoS ...