Skip to content

Commit

Permalink
Merge pull request #514 from ngdio/fix_bot_detection
Browse files Browse the repository at this point in the history
Force modern user agent in Chrome driver to pass Immoscout bot detection in headless mode
  • Loading branch information
codders authored Jan 17, 2024
2 parents 0636451 + e2eecdf commit 93108c9
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions flathunter/chrome_wrapper.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,15 @@ def get_chrome_driver(driver_arguments):
setattr(chrome_options, "headless", True)
driver = uc.Chrome(version_main=chrome_version, options=chrome_options) # pylint: disable=no-member

driver.execute_cdp_cmd(
"Network.setUserAgentOverride",
{
"userAgent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64)"
"AppleWebKit/537.36 (KHTML, like Gecko)"
"Chrome/120.0.0.0 Safari/537.36"
},
)

driver.execute_cdp_cmd('Network.setBlockedURLs',
{"urls": ["https://api.geetest.com/get.*"]})
driver.execute_cdp_cmd('Network.enable', {})
Expand Down

0 comments on commit 93108c9

Please sign in to comment.