0

实际上,我想使用 selenium python在https://coinhunt.cc/上使用不同的代理按下一个按钮。我通过抓取尝试了很多免费代理,然后在 selenium 中循环分配它们,但无法正常工作。

问题是我每次都想用新的 IP 地址访问这个 URL ( https://coinhunt.cc/ ) 来按下按钮,我创建了一个没有错误的脚本,但是免费的 IP 地址不起作用并且 url无法加载每个新的 IP 地址。所以我需要付费的 IP 地址或轮换代理,它们每天都能完美运行。请指导我这个问题。

我想用每个新的 IP 地址增加对https://coinhunt.cc/的支持。或者,如果有任何可能有用且工作正常的东西,请告诉我。我被严重困在这个阶段。

这是代码:

        ips=['ips:ports'] #free ip addresses
        for ip in ips:

            options = Options()
            options.add_argument('--proxy-server=%s' % ip)
            options.add_argument('--user-agent={Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/90.0.4430.212 Safari/537.36}')
            options.add_argument("user-data-dir=C:\\Users\\Izaan\\AppData\\Local\\Google\\Chrome\\User Data\\selenium1")
            options.add_experimental_option("excludeSwitches", ["enable-automation"])
            options.add_experimental_option('useAutomationExtension', False)
            options.add_argument("--disable-blink-features=AutomationControlled")
            options.add_argument("--disable-dev-shm-usage")
            options.add_argument("--remote-debugging-port=9222")
            options.add_argument('--no-sandbox')
            options.add_argument("--disable-extensions")
            options.add_argument("--disable-gpu")
            options.add_argument("disable-infobars")
            print('Your ip is switched to {}.'.format(ip))
            driver = webdriver.Chrome(options=options)
            try:
                driver.get('https://coinhunt.cc/')
                time.sleep(15)

            except Exception as e:
                print(e)
                time.sleep(5)




            try:
                driver.find_element_by_xpath('//*[@id="root"]/div/div[2]/div[2]/div/div/div[2]/div[2]/div/div/div[13]').click()

            except Exception as e:
                print(e)
                time.sleep(5)


            try:
                driver.find_element_by_xpath('//img[contains(@src,"/images/koala/logo.png")]/following::div[4]/button').click()
                time.sleep(7)
                driver.close()
                time.sleep(1)
            except Exception as e:
                print(e)
                driver.close()
                time.sleep(7)
4

0 回答 0