使用Python Selenium绕过Cloudfare
我只是想使用selenium python绕过cloudfare服务,我已经编写了一段代码,但它不起作用 这是我的密码:使用Python Selenium绕过Cloudfare,python,selenium,selenium-webdriver,web-scraping,selenium-chromedriver,Python,Selenium,Selenium Webdriver,Web Scraping,Selenium Chromedriver,我只是想使用selenium python绕过cloudfare服务,我已经编写了一段代码,但它不起作用 这是我的密码: import selenium from selenium import webdriver from selenium.webdriver.chrome.options import Options from selenium.webdriver.common.by import By from selenium.common.exceptions import Timeo
import selenium
from selenium import webdriver
from selenium.webdriver.chrome.options import Options
from selenium.webdriver.common.by import By
from selenium.common.exceptions import TimeoutException
from selenium.common.exceptions import NoSuchElementException
from selenium.webdriver.common.action_chains import ActionChains
from selenium.webdriver.common.keys import Keys
from selenium.webdriver.support.ui import WebDriverWait
from selenium import webdriver
options = webdriver.ChromeOptions()
options.add_experimental_option("excludeSwitches", ["enable-automation"])
options.add_experimental_option('useAutomationExtension', False)
options.add_argument("--disable-blink-features")
options.add_argument("disable-infobars")
options.add_argument("--disable-extensions")
options.add_argument("--disable-blink-features=AutomationControlled")
driver = webdriver.Chrome(options=options, executable_path=r".\chromedriver.exe")
driver.maximize_window()
driver.get('https://poocoin.app/tokens/0xef2ec90e0b8d4cdfdb090989ea1bc663f0d680bf')
当我运行代码时,我会被困在cloudfare中
请参见屏幕截图:
当我手动打开它时,它看起来是这样的
我也看到了cloudfare屏幕。
您只需添加一个等待条件,直到出现
poocoin
站点本身
from selenium.webdriver.support import expected_conditions as EC
from selenium.webdriver.support.ui import WebDriverWait
wait.until(EC.url_to_be('https://poocoin.app/tokens/0xef2ec90e0b8d4cdfdb090989ea1bc663f0d680bf'))
之后,您可以继续您的流程。您也可以等待其他条件。例如,
标题为
或该页面上存在某些元素。您所说的“但它不起作用”是什么意思?即使我手动打开链接,你看到的屏幕也会显示出来。当我手动打开链接时,它会完美地打开嗨,我已经更新了问题,请检查它,希望你理解我想说的是什么,它不起作用,因为司机被云费困住了,他们不会继续实际链接你试过我写的吗?您是否定义了等待超时?WebDriverWait(driver,1000)。直到(EC.url_to_be('))我已将超时设置为1000。在driver.get(')之后的代码是什么https://poocoin.app/tokens/0xef2ec90e0b8d4cdfdb090989ea1bc663f0d680bf)
此处显示的行?