0

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})")
Abdul Moiz
  • 15
  • 1
  • Can't tell much without the url for the website, but this answer might help: https://stackoverflow.com/questions/69245288/failed-to-establish-a-new-connection-errno-111-connection-refused/69274339#69274339 – Kamalesh S Jan 08 '22 at 14:53
  • Actually the website is ‘walmart.com’, I have used all the tricks already mentioned in the link you gave me. I have figured out that on each reload the ip rotates as i am using proxies so this might be the reason that the bot detection triggers as bot finding it stable. – Abdul Moiz Jan 08 '22 at 19:23
  • Did you try without IP rotation? and also are you using premium proxies or free ones? – Kamalesh S Jan 09 '22 at 07:44
  • The proxies are premium – Abdul Moiz Jan 09 '22 at 16:07

0 Answers0