Facebook
From Gruff Armadillo, 1 Year ago, written in Plain Text.
Embed
Download Paste or View Raw
Hits: 145
  1. from bs4 import BeautifulSoup
  2. import requests
  3. import pytesseract as loki
  4.  
  5. url = "https://services.ecourts.gov.in/ecourtindia_v6/"
  6. with requests.Session() as s:
  7.     r = s.post(url)
  8.     r = s.post(
  9.         url+"vendor/securimage/securimage_show.php?f1c86df619238773796a9fa5a02672d5")
  10.     soup = BeautifulSoup(r.text, "html5lib")
  11.     imgs = soup.findAll('img', {'id': 'captcha_image'})
  12.  
  13.     captcha_path = r"C:\\Users\\luyna\\Downloads\\captcha.png"
  14.     # save captcha
  15.     with open(captcha_path, 'wb') as f:
  16.         for chunk in r:
  17.             f.write(chunk)
  18.  
  19.     captcha_text = loki.image_to_string(
  20.         captcha_path, config='--psm 10 --oem 3 -c tessedit_char_whitelist=0123456789abcdefghijklmnopqrstuvwxyz')
  21.  
  22.     r = s.post(url, data={"cino": "mhcc020200552019",
  23.                "fcaptcha_code": captcha_text})
  24.     r = s.get(url)
  25.  
  26.     soup = BeautifulSoup(r.content, "lxml")
  27.     if "MHCC020200552019" in soup:
  28.         print(soup)