0

I try to decode captcha on python, but I don't know, how can I get it from html. I use

html = session.get(page, headers=headers).text
soup = BeautifulSoup(html, "html.parser")

And html looks like

<img src="/captcha.gif" style="width:1px;height:1px"/>

How can I exctract it? I can do it only with save image?

Petr Petrov
  • 4,090
  • 10
  • 31
  • 68

1 Answers1

0

you can get image on your PC like this:

import urllib.request
from bs4 import BeautifulSoup as BS

tag = '<img src="/captcha.gif" style="width:1px;height:1px"/>'
soup = BS(tag)
img_tag = soup.find('img')
urllib.request.urlretrieve('https://absolute/path/to'+img_tag['src'], os.getcwd() + '/temp_img')
Dmitriy Fialkovskiy
  • 3,065
  • 8
  • 32
  • 47