[您好,我坚持使用2captha api python解决captha问题。.captha由2captha api正确解决了..但是一旦提交表格,它将显示另一个captha作为检测机器人。这是发生的视频捕获:https://youtu.be/7MEhJlTtvFI
这是我的代码
def create_account(名字,姓氏,电子邮件,密码,save_file =“ yelp_accounts.csv”):password_version = Falseapikey =“”驱动程序= webdriver.Chrome(“ C:\ Users \ Admin \ PycharmProjects \ YelpBot \ drivers \ chromedriver.exe”)
driver.get("https://www.yelp.com/signup")
first_name = firstname
last_name = lastname
driver.find_element_by_id("first_name").send_keys(first_name)
driver.find_element_by_id("last_name").send_keys(last_name)
mail=email
driver.find_element_by_id("email").send_keys(mail)
pwd = password
driver.find_element_by_id("password").send_keys(pwd)
zip="84480"
driver.find_element_by_id("zip").send_keys(zip)
driver.find_element_by_id("signup-button").click()
sleep(5)
googlekey="6Le5OSYTAAAAADy8seTrWT0eqpS795iV32Gm9Ag1"
# Add these values
API_KEY = apikey # Your 2captcha API KEY
site_key = googlekey # site-key, read the 2captcha docs on how to get this
url=WebDriverWait(driver, 10).until(ec.presence_of_element_located((By.XPATH, "/html/body/div[2]/div[2]/div/div[3]/div[1]/div/div/div[1]/div[1]/form/div[3]/div/div/div/iframe"))).get_attribute("src")
print url
s = requests.Session()
# here we post site key to 2captcha to get captcha ID (and we parse it here too)
captcha_id = s.post("http://2captcha.com/in.php?key={}&method=userrecaptcha&googlekey={}&pageurl={}".format(
API_KEY, site_key, url)).text.split('|')[1]
# then we parse gresponse from 2captcha response
recaptcha_answer = s.get(
"http://2captcha.com/res.php?key={}&action=get&id={}".format(API_KEY, captcha_id)).text
print("solving ref captcha...")
while 'CAPCHA_NOT_READY' in recaptcha_answer:
sleep(5)
recaptcha_answer = s.get(
"http://2captcha.com/res.php?key={}&action=get&id={}".format(API_KEY, captcha_id)).text
recaptcha_answer = recaptcha_answer.split('|')[1]
print recaptcha_answer
driver.execute_script(
"arguments[0].style.display='inline'",
driver.find_element_by_xpath(
'//*[@id="g-recaptcha-response"]'
),
)
driver.execute_script(
'document.getElementById("g-recaptcha-response").innerHTML = "%s"'
% recaptcha_answer
)
#sleep(5)
driver.find_element_by_id('signup-button').click()
sleep(20)
首先,您可能应该在每个字段中输入每个字符之前增加一些延迟,因为站点可能会分析您的键入速度。
第二,某些站点要求在解决验证码时发送一个附加请求。在这种情况下,您应该找到并执行回调函数。这是简单的方法:https://2captcha.com/2captcha-api#callback还是很难的方法:https://captchaforum.com/threads/problem-with-invisible-recaptcha-v2-callback-function-at-mail-com-sign-up-page.56/