aboutsummaryrefslogtreecommitdiff
path: root/scrape_ecourtindia_v6/scrape_case_status.py
blob: 6a0a8677f0d29f07b6ddcc5813e69c0975c57153 (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
68
69
70
71
72
73
74
75
76
77
78
79
80
81
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'
# act = 'U Sec 96 CPC'

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

        establishments = scraper.scrape_establishments()
        if len(establishments) == 0:
                sleep(1)
                scraper.close_modal()

                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)
        else:
            for establishment in establishments:
                sleep(1)
                print(f'SELECTING ESTABLISHMENT {establishment}')

                while True:
                    scraper.select('court_est_code', establishment)
                    break

                sleep(1)
                scraper.close_modal()

                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()