aboutsummaryrefslogtreecommitdiff
path: root/scrape_ecourtindia_v6/scrape_case_status.py
blob: a8891fd9c599abb3c042c99b670998eada9f8761 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
from time import sleep
from modules.scraper_case_status import ScraperCaseStatus
from tinydb import TinyDB

db = TinyDB('db.json')

scraper = ScraperCaseStatus()

state = 'Karnataka'
act = 'Juvenile Justice (Care and Protection of Children) Act, 2015'

scraper.close_modal()
scraper.select('sess_state_code', state)
sleep(1)

for district in scraper.scrape_districts():
    print(f'SELECTING DISTRICT {district}')
    while True:
        try:
            scraper.close_modal()
            scraper.select('sess_dist_code', district)
            break
        except:
            pass
    sleep(1)

    for cmplx in scraper.scrape_complexes():
        sleep(1)
        print(f'SELECTING COMPLEX {cmplx}')
        while True:
            try:
                scraper.close_modal()
                scraper.select('court_complex_code', cmplx)
                break
            except:
                pass
        try:
            scraper.driver.switch_to.alert.accept();
            scraper.close_modal()
        except:
            pass

        for establishment in scraper.scrape_establishments():
            sleep(1)
            print(f'SELECTING ESTABLISHMENT {establishment}')
            while True:
                try:
                    scraper.close_modal()
                    scraper.select('court_est_code', establishment)
                    break
                except Exception as e:
                    print("EXCEPTION HANDLED:")
                    print(e)

            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)

scraper.driver.close()