Skip to content
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
19 changes: 14 additions & 5 deletions src/backend/expungeservice/endpoints/case_detail_page.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
from os import path
from pathlib import Path
import time

from bs4 import BeautifulSoup
from flask.views import MethodView
Expand All @@ -10,11 +11,19 @@
class CaseDetailPage(MethodView):
def get(self, id):
url = f"https://publicaccess.courts.oregon.gov/PublicAccessLogin/CaseDetail.aspx?CaseID={id}"
html = Crawler.fetch_link(url)
if html:
return CaseDetailPage._strip_links(html)
else:
return f"Case detail page with ID of {id} does not exist."

max_retries = 3
backoff_seconds = 2
# Retry loop with backoff
for attempt in range(max_retries):
html = Crawler.fetch_link(url)
if html:
return CaseDetailPage._strip_links(html)

if attempt < max_retries - 1:
time.sleep(backoff_seconds)

return f"Case detail page with ID of {id} does not exist."

@staticmethod
def _strip_links(html):
Expand Down