Tho*_*kes 3 html python selenium captcha recaptcha
hidden我在 iframe 中有一个 type 元素。我想知道是否有任何方法可以获取这个值,因为我正在使用硒。更具体地说,它是验证码字段。我试过用类似的东西拉它
#!/usr/bin/env python
from selenium import webdriver
driver=webdriver.Chrome(chrome_bin_path)
driver.get('http://websitehere.com')
print driver.find_element_by_xpath('//*[@id="recaptcha-token"]').text
Run Code Online (Sandbox Code Playgroud)
但由于它的隐藏性质,它不会返回任何内容。
下面是源代码的片段。突出显示的是感兴趣的字符串。(价值)
driver.switch_to_frame('undefined')
token_value = driver.find_element_by_id('recaptcha-token').get_attribute('value')
driver.switch_to_default_content()
Run Code Online (Sandbox Code Playgroud)