from bs4 import BeautifulSoup
import requests
import pytesseract as loki
url = "https://services.ecourts.gov.in/ecourtindia_v6/"
with requests.Session() as s:
r = s.post(url)
r = s.post(
url+"vendor/securimage/securimage_show.php?f1c86df619238773796a9fa5a02672d5")
soup = BeautifulSoup(r.text, "html5lib")
imgs = soup.findAll('img', {'id': 'captcha_image'})
captcha_path = r"C:\\Users\\luyna\\Downloads\\captcha.png"
# save captcha
with open(captcha_path, 'wb') as f:
for chunk in r:
f.write(chunk)
captcha_text = loki.image_to_string(
captcha_path, config='--psm 10 --oem 3 -c tessedit_char_whitelist=0123456789abcdefghijklmnopqrstuvwxyz')
r = s.post(url, data={"cino": "mhcc020200552019",
"fcaptcha_code": captcha_text})
r = s.get(url)
soup = BeautifulSoup(r.content, "lxml")
if "MHCC020200552019" in soup:
print(soup)
{"html5":"htmlmixed","css":"css","javascript":"javascript","php":"php","python":"python","ruby":"ruby","lua":"text\/x-lua","bash":"text\/x-sh","go":"go","c":"text\/x-csrc","cpp":"text\/x-c++src","diff":"diff","latex":"stex","sql":"sql","xml":"xml","apl":"apl","asterisk":"asterisk","c_loadrunner":"text\/x-csrc","c_mac":"text\/x-csrc","coffeescript":"text\/x-coffeescript","csharp":"text\/x-csharp","d":"d","ecmascript":"javascript","erlang":"erlang","groovy":"text\/x-groovy","haskell":"text\/x-haskell","haxe":"text\/x-haxe","html4strict":"htmlmixed","java":"text\/x-java","java5":"text\/x-java","jquery":"javascript","mirc":"mirc","mysql":"sql","ocaml":"text\/x-ocaml","pascal":"text\/x-pascal","perl":"perl","perl6":"perl","plsql":"sql","properties":"text\/x-properties","q":"text\/x-q","scala":"scala","scheme":"text\/x-scheme","tcl":"text\/x-tcl","vb":"text\/x-vb","verilog":"text\/x-verilog","yaml":"text\/x-yaml","z80":"text\/x-z80"}