diff options
| author | Nathan Kinkade <nath@nkinka.de> | 2013-11-17 01:12:53 +0000 |
|---|---|---|
| committer | Nathan Kinkade <nath@nkinka.de> | 2013-11-17 01:12:53 +0000 |
| commit | 1b58ac324f601b63e6f47cede24e430cd0af00a7 (patch) | |
| tree | ff61ab4e7463d960c0583df9c23438c9b3e4cde0 | |
| parent | 338444de70a1723e68640307c6cbb2ae5e35e621 (diff) | |
Removed the while loop, it wasn't working, and fixed a bug where main() was looping through a-z instead of stopping when a def. wasn't found.
| -rwxr-xr-x | miami-dade_clerk_courts.py | 68 |
1 files changed, 32 insertions, 36 deletions
diff --git a/miami-dade_clerk_courts.py b/miami-dade_clerk_courts.py index 07856ca..5c4b412 100755 --- a/miami-dade_clerk_courts.py +++ b/miami-dade_clerk_courts.py @@ -508,46 +508,42 @@ def main(): field_names['active_tab'] : field_values['active_tab'], } - attempt = 0 - # Try to fetch a given case 3 times before # giving up and moving to the next sequence - while attempt < 3: - case = fetch_page(post_fields) - if case: - case_soup = BeautifulSoup(case) - not_found = check_case_not_found(case_soup) - if not_found: - current_case = 'F-%s-%s' % (year, seq) - # We only want to try stripping the defendant letter on 'a', - # since for anything after we will have already tried - # stripping it, and don't want to do it again. - if defendant != 'a': - break - # Try again with no defendant sequence specification - post_fields[ field_names['case_defendant'] + field_values['field_suffix'] ] = '' - case = fetch_page(post_fields) - if case: - case_soup = BeautifulSoup(case) - not_found = check_case_not_found(case_soup) - if not_found: - # If the case wasn't found even without the defendant - # number then it really must not exist - case_not_found_count = case_not_found_count + 1 - else: - # Reset the not_found_count and process case - case_not_found_count = 0 - process_case(case_soup) - + case = fetch_page(post_fields) + if case: + case_soup = BeautifulSoup(case) + not_found = check_case_not_found(case_soup) + if not_found: + current_case = 'F-%s-%s' % (year, seq) + # We only want to try stripping the defendant letter on 'a', + # since for anything after we will have already tried + # stripping it, and don't want to do it again. + if defendant != 'a': break - else: - current_case = 'F-%s-%s-%s' % (year, seq, defendant) - # Reset the not_found_count and process case - case_not_found_count = 0 - process_case(case_soup) + # Try again with no defendant sequence specification + post_fields[ field_names['case_defendant'] + field_values['field_suffix'] ] = '' + case = fetch_page(post_fields) + if case: + case_soup = BeautifulSoup(case) + not_found = check_case_not_found(case_soup) + if not_found: + # If the case wasn't found even without the defendant + # number then it really must not exist + case_not_found_count = case_not_found_count + 1 + else: + # Reset the not_found_count and process case + case_not_found_count = 0 + process_case(case_soup) + + break + else: + current_case = 'F-%s-%s-%s' % (year, seq, defendant) + # Reset the not_found_count and process case + case_not_found_count = 0 + process_case(case_soup) else: - attempt = attempt + 1 - break + break if __name__ == '__main__': |
