Last active
December 20, 2015 15:08
-
-
Save jstvz/6151466 to your computer and use it in GitHub Desktop.
This Las Vegas Municipal Court case download script uses python Selenium and Python to download public case reports from the Courts website.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/python | |
import gzip | |
import sys | |
from selenium import webdriver | |
from selenium.webdriver.common.keys import Keys | |
def get_lvmc_case_report(caseNumber): | |
driver = webdriver.Firefox() | |
driver.get('https://secure2.lasvegasnevada.gov/defendantreport/Default.aspx') | |
casenum = driver.find_element_by_name('txt_CaseNo') | |
casenum.send_keys(caseNumber) | |
casenum.send_keys(Keys.RETURN) | |
driver.implicitly_wait("3") | |
for handle in driver.window_handles: | |
driver.switch_to_window(handle) | |
if driver.current_url == 'https://secure2.lasvegasnevada.gov/defendantreport/report.aspx': | |
filename = caseNumber + '.html.gz' | |
outfile = gzip.open(filename, 'wb') | |
outfile.write(driver.page_source) | |
outfile.close() | |
print "Wrote %s" % filename | |
driver.quit() | |
cases = ['C' + str(x) + 'A' for x in range(int(sys.argv[1]), int(sys.argv[2]), 1)] | |
for case in cases: | |
print case | |
get_lvmc_case_report(case) | |
# The time it takes to open a browser window is enough, | |
# no need to sleep | |
# sleep(randint(0,1)) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment