Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PR: fix duplicate bill import issue #5214

Merged
merged 1 commit into from
Jan 13, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 11 additions & 1 deletion scrapers/pr/bills.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ def clean_name(self, name):
def scrape(self, session=None, chamber=None, page=None):
self.seen_votes = set()
self.seen_bills = set()
self.seen_bill_identifiers = set()
chambers = [chamber] if chamber is not None else ["upper", "lower"]
for chamber in chambers:
yield from self.scrape_search_results(
Expand Down Expand Up @@ -339,7 +340,16 @@ def scrape_bill(self, chamber, session, url):
if title:
bill_id = re.findall(r"[A-Z]{2}\d{4}", title)[0]
else:
bill_id = ""
self.logger.error(f"Bill found with no bill identifier at {url}")

# PR occasionally repeats a bill at different URLs (????)
# example:
# PC0205 https://sutra.oslpr.org/medidas/152982
# PC0205 https://sutra.oslpr.org/medidas/152909
if bill_id in self.seen_bill_identifiers:
return
else:
self.seen_bill_identifiers.add(bill_id)

bill_type = self.classify_bill_type(bill_id)

Expand Down
Loading