1
我正在建立神经网络的训练集,从CAPTCHA图像中提取的各个数字。 我正在使用Python 2.7.3,lxml库和XPath选择器。提取CAPTCHA图像
从CAPTCHA获取右图像我需要提取该被加载的动态成WWW img src
并且每次都是不同的,所以我的Python代码是:
import urllib
from lxml import etree, html
adres_prefix = "https://prod.ceidg.gov.pl/CEIDG/CEIDG.Public.UI/"
adres_sufix = etree.XPath('string(//img[@class="captcha"]/@src)')
sock = urllib.urlopen("https://prod.ceidg.gov.pl/CEIDG/CEIDG.Public.UI/Search.aspx")
htmlSource = sock.read()
sock.close()
root = etree.HTML(htmlSource)
result = etree.tostring(root, pretty_print=True, method="html")
result2 = adres_sufix(root)
www = adres_prefix + result2
print www
所以每次我得到WWW:
https://prod.ceidg.gov.pl/CEIDG/CEIDG.Public.UI/captcha.ashx?id=1b7d2b6d-70a6-4ce3-bedd-fe89038fb7f3&empty=1
有什么不对,因为当把这个链接复制到我的浏览器时,我什么都没有。
源页面CAPTCHA
我不知道什么是错的。为什么XPath选择器得到'& empty = 1'? 任何想法?