From 399cda8e0ffb2ecbb77874960d37d7feebe7f62d Mon Sep 17 00:00:00 2001 From: Raghuram Subramani <raghus2247@gmail.com> Date: Mon, 07 Apr 2025 11:27:07 +0530 Subject: [PATCH] update --- flake.nix | 1 + heinous_offences/app.py | 19 +++++++++++++++++++ scrape_ecourtindia_v6/scrape_case_status.py | 50 +++++++++++++++++++++++++++++++++++++++----------- scrape_ecourtindia_v6/modules/scraper_case_status.py | 10 ++++++++++ 4 files changed, 61 insertions(+), 19 deletions(-) diff --git a/flake.nix b/flake.nix index 93bca92..d080875 100644 --- a/flake.nix +++ a/flake.nix @@ -16,6 +16,7 @@ p.fastapi p.uvicorn p.jinja2 + p.streamlit # p.pdf2image # p.openai-whisper diff --git a/heinous_offences/app.py b/heinous_offences/app.py new file mode 100644 index 0000000..d527aa8 100644 --- /dev/null +++ a/heinous_offences/app.py @@ -1,0 +1,19 @@ +import streamlit as st +from tinydb import TinyDB, Query + +db = TinyDB('db.json') + +st.title('Heinous Crime Lookup') + +section = st.number_input('Section', value=0) + +if section > 0: + offence = db.search(Query().section == str(section))[0] + st.subheader(offence['severity']) + st.write(offence['section_text']) + + st.subheader('Minimum Punishment') + st.write(offence['minimum_punishment']) + + st.subheader('Comments') + st.write(offence['comment']) diff --git a/scrape_ecourtindia_v6/scrape_case_status.py b/scrape_ecourtindia_v6/scrape_case_status.py index a8891fd..6a0a867 100644 --- a/scrape_ecourtindia_v6/scrape_case_status.py +++ a/scrape_ecourtindia_v6/scrape_case_status.py @@ -8,6 +8,7 @@ state = 'Karnataka' act = 'Juvenile Justice (Care and Protection of Children) Act, 2015' +# act = 'U Sec 96 CPC' scraper.close_modal() scraper.select('sess_state_code', state) @@ -34,34 +35,47 @@ break except: pass + try: scraper.driver.switch_to.alert.accept(); scraper.close_modal() except: pass + + establishments = scraper.scrape_establishments() + if len(establishments) == 0: + sleep(1) + scraper.close_modal() - for establishment in scraper.scrape_establishments(): - sleep(1) - print(f'SELECTING ESTABLISHMENT {establishment}') - while True: + sleep(1) + scraper.goto_acts() try: - scraper.close_modal() + scraper.select_act(act) + scraper.handle_table(db) + sleep(1) + except Exception as e: + print("EXCEPTION HANDLED:") + print(e) + else: + for establishment in establishments: + sleep(1) + print(f'SELECTING ESTABLISHMENT {establishment}') + + while True: scraper.select('court_est_code', establishment) break - except Exception as e: - print("EXCEPTION HANDLED:") - print(e) - sleep(1) - scraper.close_modal() + sleep(1) + scraper.close_modal() - sleep(1) - scraper.goto_acts() - try: - scraper.select_act(act) - scraper.handle_table(db) - except Exception as e: - print("EXCEPTION HANDLED:") - print(e) + sleep(1) + scraper.goto_acts() + try: + scraper.select_act(act) + scraper.handle_table(db) + sleep(1) + except Exception as e: + print("EXCEPTION HANDLED:") + print(e) scraper.driver.close() diff --git a/scrape_ecourtindia_v6/modules/scraper_case_status.py b/scrape_ecourtindia_v6/modules/scraper_case_status.py index b4a9ec3..cffcb1b 100644 --- a/scrape_ecourtindia_v6/modules/scraper_case_status.py +++ a/scrape_ecourtindia_v6/modules/scraper_case_status.py @@ -19,7 +19,11 @@ Scraper.__init__(self, 'https://services.ecourts.gov.in/ecourtindia_v6/?p=casestatus/index', headless=False) def select_act(self, act): - self.select('actcode', act) + try: + self.select('actcode', act) + except Exception as e: + print('EXCEPTION HANDLED:') + print(e) sleep(1) # Disposed only @@ -124,6 +128,10 @@ sleep(1) obj = self.driver.find_element(By.TAG_NAME, 'object') + if self.driver.find_element(By.ID, 'validateError').is_displayed(): + self.close_modal() + return + pdf_url = str(obj.get_attribute('data')) while True: -- rgit 0.1.5