1

I'm trying to scrape a website i tried all the options i found on the internet even proxies but my selenium is detected and i got a captcha. I tried proxies, adding arguments and options to selenium but i'm still detected, i also tried to change the user-agent. Here is the code :

from selenium import webdriver
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC
from selenium.webdriver.common.by import By
from selenium.webdriver.common.action_chains import ActionChains
from selenium.webdriver.chrome.options import Options
from selenium.webdriver.chrome.service import Service
import time
from datetime import date, timedelta,datetime
import sys
import random
import undetected_chromedriver as uc

def get_prices():
      
    driver_path=r"C:\Users\Sasha\Downloads\chromedriver_win32\chromedriver.exe"
    
    chrome_options = Options()
    chrome_options.add_argument('--disable-blink-features=AutomationControlled')
    chrome_options.add_argument('--no-sandbox')
    chrome_options.add_argument("--incognito")
    chrome_options.add_argument("disable-infobars")
    chrome_options.add_experimental_option('useAutomationExtension', False)
    chrome_options.add_experimental_option("excludeSwitches", ["enable-automation"])
    chrome_options.add_argument("--user-agent=Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/114.0.0.0 Safari/537.36");
    service=Service(driver_path)
    
    my_options=webdriver.ChromeOptions()
    my_options.add_argument( '--disable-blink-features=AutomationControlled' )
    driver=webdriver.Chrome(service=service,options=chrome_options)
    
       
    driver.get("https://www.skyscanner.fr/transport/vols/cdg/cgk/?adultsv2=1&cabinclass=economy&oym=2308&iym=2309&selectedoday=01&selectediday=05")
    time.sleep(1)
    wait = WebDriverWait(driver, 10)

Does someone has a solution please ? Thanks

sashalarso
  • 11
  • 3

0 Answers0