config
Diff
scrape_ecourtindia_v6/main.py | 13 +++++++++++--
scrape_ecourtindia_v6/scraper.py | 29 ++++++++++++++++++-----------
scrape_ecourtindia_v6/html/.keep | 0
scrape_ecourtindia_v6/pdf/.keep | 0
4 files changed, 21 insertions(+), 21 deletions(-)
@@ -1,13 +1,18 @@
from scraper import Scraper
from tinydb import TinyDB
import os
db = TinyDB('db.json')
os.makedirs("html", exist_ok=True)
os.makedirs("pdf", exist_ok=True)
if __name__ == '__main__':
m = Scraper(db)
config = {}
config['state'] = input('Select a state: ')
config['district'] = input('Select a district: ')
config['court_complex'] = input('Select a court complex: ')
config['court_establishment'] = input('Select a court establishment: ')
config['act'] = input('Select an act: ')
m = Scraper(db, config)
m.run()
m.driver.close()
@@ -14,16 +14,10 @@
import pytesseract
import tempfile
Karnataka = '3'
Bengaluru = '20'
CMM_Court_Complex = '1030134@2,5,10,11,12,13,14@Y'
Chief_Metropolitan = '10'
ACT = '23'
class Scraper:
def __init__(self, db):
def __init__(self, db, config):
self.db = db
self.config = config
self.driver = Firefox()
self.driver.get('https://services.ecourts.gov.in/ecourtindia_v6/?p=casestatus/index')
@@ -45,11 +39,11 @@
sleep(1)
element = self.driver.find_element(By.ID, i_d)
select = Select(element)
select.select_by_value(value)
select.select_by_visible_text(value)
sleep(1)
def select_act(self):
self.select('actcode', ACT)
self.select('actcode', self.config['act'])
sleep(1)
@@ -58,18 +52,19 @@
def goto_acts(self):
while True:
self.select('sess_state_code', Karnataka)
self.select('sess_dist_code', Bengaluru)
self.select('court_complex_code', CMM_Court_Complex)
self.select('sess_state_code', self.config['state'])
self.select('sess_dist_code', self.config['district'])
self.select('court_complex_code', self.config['court_complex'])
sleep(2)
if self.driver.find_element(By.CLASS_NAME, 'alert-danger-cust').is_displayed():
self.driver.execute_script('closeModel({modal_id:"validateError"})')
modal_is_open = self.driver.find_element(By.CLASS_NAME, 'alert-danger-cust').is_displayed()
if modal_is_open:
self.close_modal()
continue
break
self.select('court_est_code', Chief_Metropolitan )
self.select('court_est_code', self.config['court_establishment'])
sleep(1)
element = self.driver.find_element(By.ID, 'act-tabMenu')
@@ -94,7 +89,7 @@
sleep(3)
if self.driver.find_element(By.CLASS_NAME, 'alert-danger-cust').is_displayed():
self.driver.execute_script('closeModel({modal_id:"validateError"})')
self.close_modal()
element.clear()
else:
captcha_incomplete = False