首页 > 其他分享 >Cloudflare真人验证

Cloudflare真人验证

时间:2023-11-13 14:14:55浏览次数:32  
标签:webdriver 真人 验证 selenium driver iframe input import Cloudflare

 


# import os
# import time
# from selenium import webdriver
# from selenium.webdriver.support.ui import WebDriverWait
# from selenium.webdriver.support import expected_conditions as EC
# from selenium.webdriver.common.by import By
#
#
# # 指定webdriver的路径
# chrome_driver_path = '/home/avi/.wdm/drivers/chromedriver/linux64/113.0.5672/chromedriver'
#
# # 创建一个Chrome浏览器实例
# driver = webdriver.Chrome(executable_path=chrome_driver_path)
#
# driver.get("https://www.fimea.fi/ajankohtaista/uutiset")
# time.sleep(3)
#
# # 等待iframe出现并获取句柄
# iframe_locator = (By.XPATH, "//iframe[contains(@id,'cf-chl-widget-')]")
# iframe = WebDriverWait(driver, 10).until(EC.presence_of_element_located(iframe_locator))
#
#
#
# # # 定位到iframe
# # iframe = driver.find_element_by_id("cf-chl-widget-p4b2v") # cf-chl-widget-j29dj
# # 切换到iframe
# driver.switch_to.frame(iframe)
#
# # 登录
# # driver.find_element_by_css_selector("input[name='email']").send_keys("xxx")
# # driver.find_element_by_css_selector("input[name='password']").send_keys("xxx")
# # time.sleep(3)
# # driver.find_element_by_id("dologin").click()
#
# # 退出iframe
# driver.switch_to.default_content()
# # 切换到iframe并执行操作
# driver.switch_to.frame(iframe)
# # 在iframe中查找元素并执行操作
# element = driver.find_element_by_xpath("//input[@name='search']")
# element.send_keys("search term")
import time

from selenium import webdriver
from selenium.webdriver.common.by import By
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC

# 指定ChromeDriver路径
chrome_driver_path = "/home/avi/.wdm/drivers/chromedriver/linux64/113.0.5672/chromedriver"

# 创建ChromeDriver实例
driver = webdriver.Chrome(service=webdriver.chrome.service.Service(executable_path=chrome_driver_path))

# 打开目标页面
driver.get("https://www.fimea.fi/ajankohtaista/uutiset")

# 等待目标iframe出现
iframe_locator = (By.XPATH, "//iframe[contains(@id,'cf-chl-widget-')]")
iframe = WebDriverWait(driver, 10).until(EC.presence_of_element_located(iframe_locator))

# 切换到目标iframe
driver.switch_to.frame(iframe)
time.sleep(5)
# 等待目标input出现
input_locator = (By.XPATH, "//input[@type='checkbox']")
input_box = WebDriverWait(driver, 10).until(EC.presence_of_element_located(input_locator))
time.sleep(5)
# 点击目标input
input_box.click()
time.sleep(5)

# 切回主页面
driver.switch_to.default_content()


from selenium import webdriver
from selenium.webdriver.common.by import By
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC

# 指定ChromeDriver路径
chrome_driver_path = "/home/avi/.wdm/drivers/chromedriver/linux64/113.0.5672/chromedriver"

# 创建ChromeDriver实例
driver = webdriver.Chrome(service=webdriver.chrome.service.Service(executable_path=chrome_driver_path))

# 打开目标页面
driver.get("https://www.fimea.fi/ajankohtaista/uutiset")

# 等待目标iframe出现
iframe_locator = (By.XPATH, "//iframe[contains(@id,'cf-chl-widget-')]")
iframe = WebDriverWait(driver, 10).until(EC.presence_of_element_located(iframe_locator))

# 切换到目标iframe
driver.switch_to.frame(iframe)

# 等待目标input出现
input_locator = (By.XPATH, "//input[@type='checkbox']")
input_box = WebDriverWait(driver, 10).until(EC.presence_of_element_located(input_locator))

# 点击目标input
input_box.click()

# 切回主页面
driver.switch_to.default_content()

标签:webdriver,真人,验证,selenium,driver,iframe,input,import,Cloudflare
From: https://www.cnblogs.com/avivi/p/17828960.html

相关文章

  • 浅尝poc编写工具+漏洞验证xpoc
    一、快速编写poc工具为了方便打点找到了一个在线编写poc的网站:https://poc.xray.cool/ 可配合xpoc批量利用。在线版(个人觉得本地版好用)  本地版(可验证是否有效):①windows下载链接:https://ctstack-oss.oss-cn-beijing.aliyuncs.com/tool/c39865a939edf5d7f4a37017c......
  • SEM :验证模型
    验证模型是SEM中至关重要的一步,它帮助确定我们提出的理论模型是否与实际观察到的数据相一致。验证模型的过程通常包括以下几个步骤:设定假设(HypothesisSpecification):在建立SEM之前,我们首先要明确定义我们的假设,即变量之间的关系。这些假设形成了我们将要验证的理论模型。模......
  • 生成随机验证码
    首先要导入生成图片相关模块:fromPILimportImage,ImageDraw,ImageFont"""Image:生成图片ImageDraw:能够在图片上乱涂乱画ImageFont:控制字体样式""" 为图片生成随机三基色defget_random():returnrandom.randint(0,255),random.randint(0,255),random......
  • 验证码
    importrandomfromPILimportImage,ImageDraw,ImageFont,ImageFilterdefcheck_code(width=120,height=30,char_length=5,font_file='Monaco.ttf',font_size=28): code=[] img=Image.new(mode='RGB',size=(width,height),color=(2......
  • 随机生成图片验证码
    随机生成验证码fromPILimportImage,ImageDraw,ImageFontimportrandom随机颜色1(背景颜色):defrndColor():return(random.randint(170,250),random.randint(170,250),random.randint(170,250))随机颜色2(数字或字母颜色):defrnd......
  • 多因素验证如何让企业邮箱系统登录更安全?
    企业邮箱系统作为基础的办公软件之一,既是企业内外沟通的重要工具,也是连接企业多个办公平台的桥梁,往往涉及到客户隐私、业务信息、企业机密等等。为了保护邮箱账户的安全,设置登陆密码无疑是保护账户安全的常用措施之一。然而随着互联网木马和攻击的日益猖獗,普通的用户名及密码的认证......
  • JavaScript实现完整的表单验证对邮箱用户名和密码一致性检测并拦截提交-----前端
    完整的表单验证HTML网页使用JS完成用户名密码一致性和邮箱验证<!DOCTYPEhtml><!--这是HTML的注释--><htmllang="en"id="myHtml"> <head> <!--这里不是设置了编码,而是告诉浏览器,用什么编码方式打开文件避免乱码--> <metacharset="UTF-8"> <metaname......
  • ESXI内虚拟服务器安装VMware tools报Windows无法验证此驱动程序软件的发布者
    ESXI内虚拟服务器安装VMwaretools报Windows无法验证此驱动程序软件的发布者 安装VMwaretools时,报Windows无法验证此驱动程序软件的发布者提示无法安装驱动后,自动回滚,导致安装失败。后来发现是WIN2008R2虚拟服务器少了KB4474419补丁,下载这个补丁的镜像文件(下载链接:https......
  • Spring注入Hibernate验证框架
    Spring配置文件<!--EnablestheSpringMVC@Controllerprogrammingmodel--> <mvc:annotation-drivenvalidator="validator"/> <!--配置数据校验--> <beanid="messageSource" class="org.springframework.context.suppor......
  • Element Plus 动态表单验证
    <divv-for="(item,index)informList":key="index"><el-form:ref="(el)=>{formRefs(el)}":model="item"><el-form-item><el-inputv-model="item.name"></el-input......