Python:从网址

时间:2017-08-09 15:45:47

标签: python beautifulsoup python-requests urllib captcha

我需要检测来自验证码图像的符号,这是我从网址获取的。 我用代码

session = requests.Session()
headers = {
        'User-Agent': 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_12_5) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/60.0.3112.90 Safari/537.36',
        'Accept': 'text/html,application/xhtml+xml,application/xml,image/webp,image/apng,image/*,*/*;q=0.8'
    }
html = session.get(page, headers=headers).text
print(session.get(page, headers=headers).url)
soup = BeautifulSoup(html, "html.parser")
img_link = soup.find('img')
urllib.request.urlretrieve(urllib.parse.urljoin(page, img_link['src']), path_name)

但是我收到了错误

urllib.error.URLError: <urlopen error [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed (_ssl.c:749)>

我检查了网址和img_link ['src'],看起来像是

https://moskva.tiu.ru/Tehnicheskie-moyuschie-sredstva;50
/captcha.gif

我该如何解决?

0 个答案:

没有答案