def get_pacer_case_id(self): # It's tempting to get this value from the URL in the first cell, but # that URL can sometimes differ from the URL used in the goDLS function. # When that's the case, the download fails. try: onclick = self.element.xpath('./td[3]//@onclick')[0] except IndexError: pass else: if 'goDLS' in onclick: # Sometimes the onclick is something else, like in insb's free # opinion report. return reverse_goDLS_function(onclick)['caseid'] # No onclick, onclick isn't a goDLS link, etc. Try second format. if self._sort_order == 'case_number': try: # This tends to work in the bankr. courts. href = self.element.xpath('./td[1]//@href')[0] except IndexError: logger.info("No content provided in first cell of row. Using " "last good row for pacer_case_id, docket_number, " "and case_name.") return self.last_good_row.pacer_case_id elif self._sort_order == 'date_filed': href = self.element.xpath('./td[2]//@href')[0] return get_pacer_case_id_from_docket_url(href)
def test_getting_case_id_from_urls(self): qa_pairs = (( 'https://ecf.almd.uscourts.gov/cgi-bin/DktRpt.pl?56120', '56120' ), ('https://ecf.azb.uscourts.gov/cgi-bin/iquery.pl?625371913403797-L_9999_1-0-663150', '663150')) for q, a in qa_pairs: self.assertEqual(get_pacer_case_id_from_docket_url(q), a)
def test_getting_case_id_from_urls(self): qa_pairs = ( ('https://ecf.almd.uscourts.gov/cgi-bin/DktRpt.pl?56120', '56120'), ('https://ecf.azb.uscourts.gov/cgi-bin/iquery.pl?625371913403797-L_9999_1-0-663150', '663150') ) for q, a in qa_pairs: self.assertEqual(get_pacer_case_id_from_docket_url(q), a)