How can I avoid that the website thinks that I'm a robot?

25 views
Skip to first unread message

Kenneth Vandbæk

unread,
Jun 14, 2024, 8:34:37 AM (12 days ago) Jun 14
to Selenium Users
Hi

I'm trying to find info from a site, but I'm facing that the site thinks that I'm a robot, which I am of course, but because of the error the page is not fully loaded.

How can I avoid that?


Skærmbillede 2024-06-12 133554.png
It literal says: "When you visited our site, something about your browser gave us the impression that you are a robot."

And this dos not:
https://www.sas.dk

Br
Kenneth

Very simple code here.
from selenium import webdriver
from selenium.webdriver.common.by import By
from selenium.webdriver.chrome.service import Service
from selenium.webdriver.chrome.options import Options
from webdriver_manager.chrome import ChromeDriverManager

import time


options = Options()
#options.add_argument('--headless')
options.add_argument('--disable-gpu')
options.add_argument('user-agent=Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/91.0.4472.124 Safari/537.36')
options.add_argument("--start-maximized")
options.add_experimental_option("excludeSwitches",["enable-automation"])

# Set up the WebDriver
driver = webdriver.Chrome(options=options, service=Service(ChromeDriverManager().install()))

try:

    driver.get('https://www.sas.dk/book/flights/?search=RT_CPH-ORD-20240627-20240630_a1c0i0y0&view=upsell&bookingFlow=points&cepId=&sortBy=rec,rec&filterBy=all,all')
    #driver.get('https://www.sas.dk')

    time.sleep(30)  # Simulate a delay

    # Wait for the page to load
    driver.implicitly_wait(30)

    # Extract page content
    page_content = driver.page_source

    # Print the content
    print(page_content)
finally:

    # Close the browser
    driver.quit()

Reply all
Reply to author
Forward
0 new messages