1. Anuncie Aqui ! Entre em contato fdantas@4each.com.br

[Python] How to avoid Selenium detection or change approach

Discussão em 'Python' iniciado por Stack, Setembro 12, 2024.

  1. Stack

    Stack Membro Participativo

    Goal


    I want to create a bot that would automatically edit products one by one on an online shop:

    1. Open main list of products
    2. Click on "EDIT" on n product (new window opens)
      • on opened window click some button, wait for page load, enter some text and select const that pops up
      • click on "SAVE"
      • exit the window
    3. iterate product
    4. go to step 2
    Problem


    Currently my problem is that I get captcha and/or blocked even if I just do driver.get("link") and use the selenium browser as human. I suppose the problem is with meta data that I send to the website.

    My attempt


    My final code to "mask" selenium was sourced from different stackoverflow's threads:

    from selenium import webdriver
    from fake_useragent import UserAgent
    from time import sleep

    added_product = "PAKIET OCHRONY - GWARANCJA NA 2 LATA"

    ua = UserAgent()
    user_agent = ua.chrome
    print(user_agent)

    options = webdriver.ChromeOptions()
    # options.add_argument(f'--user-agent={user_agent}')
    options.add_argument("--disable-blink-features")
    options.add_argument("--disable-blink-features=AutomationControlled")

    options.add_experimental_option("excludeSwitches", ["enable-automation"])
    options.add_experimental_option('useAutomationExtension', False)

    driver = webdriver.Chrome(options=options)


    driver.get("https://allegro.pl")

    driver.maximize_window()
    sleep(1000)



    The thing is that I can be there and monitor what's happening on the screen, I just want at least partial automation. What I thought would be good approach is to use my default "human" browser and make a script that would click inside of it. What I lack is knowledge of some kind of technology that can do this.

    TL;DR


    I need to do simple clicks/text input over windows that open whenever I iterate through products.

    Continue reading...

Compartilhe esta Página