Abdul Moiz
Abdul Moiz

Reputation: 15

The bot I have made keeps get detecting

Hey there I am trying to automate a buying process but there is some abnormal behaviour, that sometimes (very few) the bot is able to make till the end and the rest of the time it is being detected in the middle or in the beggining of the process, I have heard that the IP I am using rotates in the middle of the process and this can be the reason, I am attaching the code for selenium initiazation I am doing, I have used every possible thing, do help please.

def __init__(self,url):
    self.url = url

def get_selenium_res(self):
    try:
        software_names = [SoftwareName.CHROME.value]
        operating_systems = [OperatingSystem.WINDOWS.value,OperatingSystem.LINUX.value]
        user_agent_rotator = UserAgent(software_names=software_names,operating_systems=operating_systems,limit=1000)
        user_agent = user_agent_rotator.get_random_user_agent()
        print(user_agent)
        options = Options()
        options.add_argument('--no-sandbox')
        options.add_argument("start-maximized")
        options.add_argument('--disable-gpu')
        options.add_experimental_option("excludeSwitches", ["enable-automation"])
        options.add_argument('--disable-blink-features=AutomationControlled')

        options.add_argument(f'user-agent={user_agent}')

        PROXY = "http://pl.smartproxy.com:20000"
        proxy = Proxy()
        proxy.proxy_type = ProxyType.MANUAL
        proxy.autodetect = False
        capabilities = webdriver.DesiredCapabilities.CHROME
        proxy.http_proxy = PROXY
        proxy.ssl_proxy = PROXY
        proxy.add_to_capabilities(capabilities)
        browser = uc.Chrome(executable_path='chromedriver.exe',chrome_options=options)#Remove navigator.webdriver Flag using JavaScript
        browser.execute_script("Object.defineProperty(navigator, 'webdriver', {get: () => undefined})")

Upvotes: 0

Views: 156

Answers (0)

Related Questions