Selenium获得了php captcha图像

时间:2016-10-19 12:59:21

标签: python selenium

我试图解析有验证码的网页。验证码由PHP生成:

<img src="/captcha.php" border="0" align="absmiddle">

我做什么:

   self.driver = webdriver.Chrome()
   img = self.driver.find_element_by_xpath('//table/tbody/tr/td/img')
   scr = img.get_attribute('src')

但它包含captcha.php,我希望看到base64。

有没有办法通过php脚本返回该图像?

1 个答案:

答案 0 :(得分:0)

from this answer you can download the image:

# download the image
urllib.urlretrieve(src, "captcha.png")