Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/300.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 向Discord提交hcaptcha验证码令牌以使用selenium创建帐户_Python_Selenium_Discord_Captcha_2captcha - Fatal编程技术网

Python 向Discord提交hcaptcha验证码令牌以使用selenium创建帐户

Python 向Discord提交hcaptcha验证码令牌以使用selenium创建帐户,python,selenium,discord,captcha,2captcha,Python,Selenium,Discord,Captcha,2captcha,我正在使用python selenium创建一个Discord帐户(),但它受到了hcaptcha的保护。我有一个验证码API(2captcha/capmonster)来返回验证码令牌,并将其放入g-captcha-response文本区域。通常有一个提交按钮,您可以在之后单击该按钮,然后允许您访问该站点(如果验证码令牌正确),但一旦您手动完成hcaptcha,Discord会自动重定向您。我假设Discord正在使用hcaptcha回调函数。但是我没有找到回调函数,所以我可以在输入captch

我正在使用python selenium创建一个Discord帐户(),但它受到了hcaptcha的保护。我有一个验证码API(2captcha/capmonster)来返回验证码令牌,并将其放入
g-captcha-response文本区域
。通常有一个提交按钮,您可以在之后单击该按钮,然后允许您访问该站点(如果验证码令牌正确),但一旦您手动完成hcaptcha,Discord会自动重定向您。我假设Discord正在使用hcaptcha回调函数。但是我没有找到回调函数,所以我可以在输入captcha令牌后调用它

以下是我目前掌握的代码:

随机导入
导入请求
导入时间
从webdriver_manager.chrome导入ChromeDriverManager
从selenium导入webdriver
从selenium.webdriver.support.ui导入WebDriverWait
从selenium.webdriver.support将预期的_条件导入为EC
从selenium.webdriver.common.by导入
从selenium.webdriver.common.action\u链导入ActionChains
从selenium.webdriver.common.keys导入密钥
电子邮件=”example@gmail.com"
username=“exampleusername”
password=“examplepassword”
driver=webdriver.Chrome(ChromeDriverManager().install())
司机,上车https://discord.com/register')
WebDriverWait(driver,1).until(EC.presence_of_element_located((By.XPATH,“//input[@type='email']))
驱动程序。通过xpath(//input[@type='email'])查找元素。发送密钥(email)#email
驱动程序。通过xpath(//input[@type='text'])查找元素。发送密钥(用户名)#用户名
驱动程序。通过xpath(//input[@type='password'])查找元素。发送密钥(密码)#密码
驱动程序。通过xpath('/*[@id=“app mount”]/div[2]/div/div[2]/div/form/div/div[2]/div[4]/div[1]/div[1]/div/div/div/div/div/div[2]/div')查找元素。单击()
动作=动作链(驱动程序)
动作。发送密钥(str(random.randint(1,12)))#月
操作。发送\u键(键。输入)
动作。发送密钥(str(random.randint(1,28))#天
操作。发送\u键(键。输入)
行动。发送密钥(str(random.randint(1989,2000)))#年
actions.perform()
尝试:
驱动程序。通过类名称(“inputDefault-3JxKJ2”)查找元素。单击()#同意条款和条件
除:
通过
驱动程序。按类名称(“按钮-3k0cO7”)查找元素。单击()#提交按钮
#获取验证码密钥
站点密钥='f5561ba9-8f1e-40ca-9b5b-a0b3f719ef34'
url=”https://discordapp.com/register"
API_KEY=“CAPMONSTER API KEY”
s=请求。会话()
数据发布={
“客户端密钥”:API_密钥,
“任务”:
{
“类型”:“HCaptchaTaskProxyless”,
“网站url”:url,
“网站密钥”:网站密钥
}
}
验证码id=s.post(“https://api.capmonster.cloud/createTask,json=data_post).json()
数据获取={
“客户端密钥”:API_密钥,
“任务id”:验证码id[“任务id”]
}
captcha_answer=s.get(“https://api.capmonster.cloud/getTaskResult,json=data_get).json()
当验证码应答['status']=“processing”:
时间。睡眠(5)
captcha_answer=s.get(“https://api.capmonster.cloud/getTaskResult,json=data_get).json()
验证码令牌=验证码应答[“解决方案”][“gRecaptchaResponse”]
driver.execute_脚本(f'document.getElementsByName(“g-recaptcha-response”)[0].innerText=“{captcha_令牌}””)#将captcha令牌放入g-recaptcha-response文本区域
driver.execute_脚本(f'document.getElementsByName(“h-captcha-response”)[0]。innerText=“{captcha_-token}”;”
#提交验证码令牌的代码

您找到提交绕过令牌的解决方案了吗?没有,我还没有更新这方面的任何信息?还没找到。我有点放弃了,因为我什么都找不到