Skip to content

Commit

Permalink
Merge branch 'main' into fix_utah
Browse files Browse the repository at this point in the history
  • Loading branch information
flooie authored Nov 18, 2024
2 parents dfc5be8 + 16d6c10 commit 30f7486
Show file tree
Hide file tree
Showing 6 changed files with 79 additions and 96 deletions.
94 changes: 53 additions & 41 deletions juriscraper/opinions/united_states/state/kan_p.py
Original file line number Diff line number Diff line change
@@ -1,42 +1,81 @@
# Scraper for Kansas Supreme Court (published)
# CourtID: kan_p

from juriscraper.AbstractSite import logger
from juriscraper.OpinionSiteLinear import OpinionSiteLinear


class Site(OpinionSiteLinear):
court_filter = "Supreme Court"
status_filter = "Published"

def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)
self.court_id = self.__module__
self.url = "https://www.kscourts.org/Cases-Decisions/Decisions"
self.url = "https://www.kscourts.gov/Cases-Decisions/Decisions"
self.request["verify"] = False
self.status = "Published"
self.court = "Supreme Court"
self.request["headers"].update(
{
"Referer": "https://kscourts.gov/Cases-Decisions/Decisions",
"Host": "kscourts.gov",
"Origin": "https://kscourts.gov",
}
)

def _process_html(self):
if not self.test_mode_enabled():
# Loading from a fresh session causes an error page
self.html = self._download()
self._update_parameters()
self.html = self._download()

for row in self.html.xpath(".//tr"):
date_filed, docket_number, case_name, court, status = row.xpath(
".//td/a/text()"
)
if court != self.court_filter or status != self.status_filter:
# Check for bug seen on #1222
logger.error(
"Filters are not working, we got an opinion from %s", court
)
continue

url = row.xpath(".//td/a")[0].get("href")
self.cases.append(
{
"status": status,
"date": date_filed,
"docket": docket_number,
"name": case_name,
"url": url,
}
)

def _update_parameters(self):
""""""
"""Apply filters through a form data POST request"""
self.method = "POST"
view_state = self.html.xpath("//input[@id='__VIEWSTATE']")[0].get(
"value"
)
VIEWSTATEGENERATOR = self.html.xpath(
view_state_generator = self.html.xpath(
"//input[@id='__VIEWSTATEGENERATOR']"
)[0].get("value")
CMSCsrfToken = self.html.xpath("//input[@id='__CMSCsrfToken']")[0].get(
"value"
)
data = {
"__CMSCsrfToken": CMSCsrfToken,
cms_csrf_token = self.html.xpath("//input[@id='__CMSCsrfToken']")[
0
].get("value")
self.parameters = {
"__CMSCsrfToken": cms_csrf_token,
"__EVENTTARGET": "",
"__EVENTARGUMENT": "",
"lng": "en-US",
"__VIEWSTATEGENERATOR": VIEWSTATEGENERATOR,
"__VIEWSTATEGENERATOR": view_state_generator,
"__SCROLLPOSITIONX": "0",
"__SCROLLPOSITIONY": "239",
"__SCROLLPOSITIONY": "0",
"p$lt$ctl01$SmartSearchBox3$txtWord_exWatermark_ClientState": "",
"p$lt$ctl01$SmartSearchBox3$txtWord": "",
"p$lt$zonePagePlaceholder$pageplaceholder$p$lt$ctl02$OpinionFilter1$filterControl$txtSearch": "",
"p$lt$zonePagePlaceholder$pageplaceholder$p$lt$ctl02$OpinionFilter1$filterControl$drpPublished": self.status,
"p$lt$zonePagePlaceholder$pageplaceholder$p$lt$ctl02$OpinionFilter1$filterControl$drpCourt": self.court,
"p$lt$zonePagePlaceholder$pageplaceholder$p$lt$ctl02$OpinionFilter1$filterControl$drpPublished": self.status_filter,
"p$lt$zonePagePlaceholder$pageplaceholder$p$lt$ctl02$OpinionFilter1$filterControl$drpCourt": self.court_filter,
"p$lt$zonePagePlaceholder$pageplaceholder$p$lt$ctl02$OpinionFilter1$filterControl$drpSortBy": "Sort By",
"p$lt$zonePagePlaceholder$pageplaceholder$p$lt$ctl02$OpinionFilter1$filterControl$btnFilter": "Apply Filters",
"p$lt$zonePagePlaceholder$pageplaceholder$p$lt$ctl03$AccordionLayout1$acc_AccordionExtender_ClientState": "-1",
Expand All @@ -45,30 +84,3 @@ def _update_parameters(self):
"p$lt$ctl09$SmartSearchBox1$txtWord": "",
"__VIEWSTATE": view_state,
}
self.parameters = data
self.method = "POST"
self.request["verify"] = False

def _process_html(self):
self.method = "POST"
if not self.test_mode_enabled():
if (
self.url
== "https://www.kscourts.org/Cases-Decisions/Decisions"
):
self._update_parameters()
self.html = super()._download()
for row in self.html.xpath(".//tr"):
date_filed, docket_number, case_name, court, status = row.xpath(
".//td/a/text()"
)
url = row.xpath(".//td/a")[0].get("href")
self.cases.append(
{
"status": status,
"date": date_filed,
"docket": docket_number,
"name": case_name,
"url": url,
}
)
7 changes: 2 additions & 5 deletions juriscraper/opinions/united_states/state/kan_u.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,5 @@


class Site(kan_p.Site):
def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)
self.court_id = self.__module__
self.status = "Unpublished"
self.court = "Supreme Court"
court_filter = "Supreme Court"
status_filter = "Unpublished"
7 changes: 2 additions & 5 deletions juriscraper/opinions/united_states/state/kanctapp_p.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,5 @@


class Site(kan_p.Site):
def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)
self.court_id = self.__module__
self.status = "Published"
self.court = "Court of Appeals"
court_filter = "Court of Appeals"
status_filter = "Published"
7 changes: 2 additions & 5 deletions juriscraper/opinions/united_states/state/kanctapp_u.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,5 @@


class Site(kan_p.Site):
def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)
self.court_id = self.__module__
self.status = "Unpublished"
self.court = "Court of Appeals"
court_filter = "Court of Appeals"
status_filter = "Unpublished"
30 changes: 10 additions & 20 deletions tests/examples/opinions/united_states/kanctapp_p_example.html
Original file line number Diff line number Diff line change
Expand Up @@ -1660,8 +1660,7 @@ <h3>Filed November 3, 2023</h3>
v. Phipps</a>
</td>
<td>
<a href="/KSCourts/media/KsCourts/Opinions/125269.pdf?ext=.pdf">Court
of Appeals</a>
<a href="/KSCourts/media/KsCourts/Opinions/125269.pdf?ext=.pdf">Court of Appeals</a>
</td>
<td>
<a href="/KSCourts/media/KsCourts/Opinions/125269.pdf?ext=.pdf">Published</a>
Expand Down Expand Up @@ -1690,8 +1689,7 @@ <h3>Filed November 3, 2023</h3>
v. McCaslin</a>
</td>
<td>
<a href="/KSCourts/media/KsCourts/Opinions/125657.pdf?ext=.pdf">Court
of Appeals</a>
<a href="/KSCourts/media/KsCourts/Opinions/125657.pdf?ext=.pdf">Court of Appeals</a>
</td>
<td>
<a href="/KSCourts/media/KsCourts/Opinions/125657.pdf?ext=.pdf">Published</a>
Expand Down Expand Up @@ -1720,8 +1718,7 @@ <h3>Filed November 3, 2023</h3>
v. Detimore</a>
</td>
<td>
<a href="/KSCourts/media/KsCourts/Opinions/125119.pdf?ext=.pdf">Court
of Appeals</a>
<a href="/KSCourts/media/KsCourts/Opinions/125119.pdf?ext=.pdf">Court of Appeals</a>
</td>
<td>
<a href="/KSCourts/media/KsCourts/Opinions/125119.pdf?ext=.pdf">Published</a>
Expand Down Expand Up @@ -1751,8 +1748,7 @@ <h3>Filed November 3, 2023</h3>
v. Higdon</a>
</td>
<td>
<a href="/KSCourts/media/KsCourts/Opinions/125672.pdf?ext=.pdf">Court
of Appeals</a>
<a href="/KSCourts/media/KsCourts/Opinions/125672.pdf?ext=.pdf">Court of Appeals</a>
</td>
<td>
<a href="/KSCourts/media/KsCourts/Opinions/125672.pdf?ext=.pdf">Published</a>
Expand Down Expand Up @@ -1781,8 +1777,7 @@ <h3>Filed November 3, 2023</h3>
v. Clingerman</a>
</td>
<td>
<a href="/KSCourts/media/KsCourts/Opinions/125695.pdf?ext=.pdf">Court
of Appeals</a>
<a href="/KSCourts/media/KsCourts/Opinions/125695.pdf?ext=.pdf">Court of Appeals</a>
</td>
<td>
<a href="/KSCourts/media/KsCourts/Opinions/125695.pdf?ext=.pdf">Published</a>
Expand Down Expand Up @@ -1811,8 +1806,7 @@ <h3>Filed November 3, 2023</h3>
v. Nelson</a>
</td>
<td>
<a href="/KSCourts/media/KsCourts/Opinions/125274.pdf?ext=.pdf">Court
of Appeals</a>
<a href="/KSCourts/media/KsCourts/Opinions/125274.pdf?ext=.pdf">Court of Appeals</a>
</td>
<td>
<a href="/KSCourts/media/KsCourts/Opinions/125274.pdf?ext=.pdf">Published</a>
Expand Down Expand Up @@ -1841,8 +1835,7 @@ <h3>Filed November 3, 2023</h3>
v. Koerner</a>
</td>
<td>
<a href="/KSCourts/media/KsCourts/Opinions/125787.pdf?ext=.pdf">Court
of Appeals</a>
<a href="/KSCourts/media/KsCourts/Opinions/125787.pdf?ext=.pdf">Court of Appeals</a>
</td>
<td>
<a href="/KSCourts/media/KsCourts/Opinions/125787.pdf?ext=.pdf">Published</a>
Expand Down Expand Up @@ -1871,8 +1864,7 @@ <h3>Filed November 3, 2023</h3>
Wichita, Inc. v. Filardo</a>
</td>
<td>
<a href="/KSCourts/media/KsCourts/Opinions/119563.pdf?ext=.pdf">Court
of Appeals</a>
<a href="/KSCourts/media/KsCourts/Opinions/119563.pdf?ext=.pdf">Court of Appeals</a>
</td>
<td>
<a href="/KSCourts/media/KsCourts/Opinions/119563.pdf?ext=.pdf">Published</a>
Expand Down Expand Up @@ -1902,8 +1894,7 @@ <h3>Filed November 3, 2023</h3>
of Salina, Kansas</a>
</td>
<td>
<a href="/KSCourts/media/KsCourts/Opinions/125456.pdf?ext=.pdf">Court
of Appeals</a>
<a href="/KSCourts/media/KsCourts/Opinions/125456.pdf?ext=.pdf">Court of Appeals</a>
</td>
<td>
<a href="/KSCourts/media/KsCourts/Opinions/125456.pdf?ext=.pdf">Published</a>
Expand Down Expand Up @@ -1932,8 +1923,7 @@ <h3>Filed November 3, 2023</h3>
v. Spilman</a>
</td>
<td>
<a href="/KSCourts/media/KsCourts/Opinions/124775.pdf?ext=.pdf">Court
of Appeals</a>
<a href="/KSCourts/media/KsCourts/Opinions/124775.pdf?ext=.pdf">Court of Appeals</a>
</td>
<td>
<a href="/KSCourts/media/KsCourts/Opinions/124775.pdf?ext=.pdf">Published</a>
Expand Down
30 changes: 10 additions & 20 deletions tests/examples/opinions/united_states/kanctapp_u_example.html
Original file line number Diff line number Diff line change
Expand Up @@ -1659,8 +1659,7 @@ <h3>Filed November 3, 2023</h3>
v. Elnicki</a>
</td>
<td>
<a href="/KSCourts/media/KsCourts/Opinions/123914.pdf?ext=.pdf">Court
of Appeals</a>
<a href="/KSCourts/media/KsCourts/Opinions/123914.pdf?ext=.pdf">Court of Appeals</a>
</td>
<td>
<a href="/KSCourts/media/KsCourts/Opinions/123914.pdf?ext=.pdf">Unpublished</a>
Expand Down Expand Up @@ -1689,8 +1688,7 @@ <h3>Filed November 3, 2023</h3>
v. State</a>
</td>
<td>
<a href="/KSCourts/media/KsCourts/Opinions/124279.pdf?ext=.pdf">Court
of Appeals</a>
<a href="/KSCourts/media/KsCourts/Opinions/124279.pdf?ext=.pdf">Court of Appeals</a>
</td>
<td>
<a href="/KSCourts/media/KsCourts/Opinions/124279.pdf?ext=.pdf">Unpublished</a>
Expand Down Expand Up @@ -1719,8 +1717,7 @@ <h3>Filed November 3, 2023</h3>
v. Ward</a>
</td>
<td>
<a href="/KSCourts/media/KsCourts/Opinions/125186.pdf?ext=.pdf">Court
of Appeals</a>
<a href="/KSCourts/media/KsCourts/Opinions/125186.pdf?ext=.pdf">Court of Appeals</a>
</td>
<td>
<a href="/KSCourts/media/KsCourts/Opinions/125186.pdf?ext=.pdf">Unpublished</a>
Expand Down Expand Up @@ -1749,8 +1746,7 @@ <h3>Filed November 3, 2023</h3>
re J.S. and K.G.</a>
</td>
<td>
<a href="/KSCourts/media/KsCourts/Opinions/125296.pdf?ext=.pdf">Court
of Appeals</a>
<a href="/KSCourts/media/KsCourts/Opinions/125296.pdf?ext=.pdf">Court of Appeals</a>
</td>
<td>
<a href="/KSCourts/media/KsCourts/Opinions/125296.pdf?ext=.pdf">Unpublished</a>
Expand Down Expand Up @@ -1779,8 +1775,7 @@ <h3>Filed November 3, 2023</h3>
v. Eismann</a>
</td>
<td>
<a href="/KSCourts/media/KsCourts/Opinions/125904.pdf?ext=.pdf">Court
of Appeals</a>
<a href="/KSCourts/media/KsCourts/Opinions/125904.pdf?ext=.pdf">Court of Appeals</a>
</td>
<td>
<a href="/KSCourts/media/KsCourts/Opinions/125904.pdf?ext=.pdf">Unpublished</a>
Expand Down Expand Up @@ -1809,8 +1804,7 @@ <h3>Filed November 3, 2023</h3>
re Adoption of V.A.</a>
</td>
<td>
<a href="/KSCourts/media/KsCourts/Opinions/126006.pdf?ext=.pdf">Court
of Appeals</a>
<a href="/KSCourts/media/KsCourts/Opinions/126006.pdf?ext=.pdf">Court of Appeals</a>
</td>
<td>
<a href="/KSCourts/media/KsCourts/Opinions/126006.pdf?ext=.pdf">Unpublished</a>
Expand Down Expand Up @@ -1839,8 +1833,7 @@ <h3>Filed November 3, 2023</h3>
re S.T.</a>
</td>
<td>
<a href="/KSCourts/media/KsCourts/Opinions/126280.pdf?ext=.pdf">Court
of Appeals</a>
<a href="/KSCourts/media/KsCourts/Opinions/126280.pdf?ext=.pdf">Court of Appeals</a>
</td>
<td>
<a href="/KSCourts/media/KsCourts/Opinions/126280.pdf?ext=.pdf">Unpublished</a>
Expand Down Expand Up @@ -1869,8 +1862,7 @@ <h3>Filed November 3, 2023</h3>
v. State</a>
</td>
<td>
<a href="/KSCourts/media/KsCourts/Opinions/124977.pdf?ext=.pdf">Court
of Appeals</a>
<a href="/KSCourts/media/KsCourts/Opinions/124977.pdf?ext=.pdf">Court of Appeals</a>
</td>
<td>
<a href="/KSCourts/media/KsCourts/Opinions/124977.pdf?ext=.pdf">Unpublished</a>
Expand Down Expand Up @@ -1899,8 +1891,7 @@ <h3>Filed November 3, 2023</h3>
v. Bradley</a>
</td>
<td>
<a href="/KSCourts/media/KsCourts/Opinions/125198.pdf?ext=.pdf">Court
of Appeals</a>
<a href="/KSCourts/media/KsCourts/Opinions/125198.pdf?ext=.pdf">Court of Appeals</a>
</td>
<td>
<a href="/KSCourts/media/KsCourts/Opinions/125198.pdf?ext=.pdf">Unpublished</a>
Expand Down Expand Up @@ -1929,8 +1920,7 @@ <h3>Filed November 3, 2023</h3>
re Marriage of S.D. and L.D.</a>
</td>
<td>
<a href="/KSCourts/media/KsCourts/Opinions/125231.pdf?ext=.pdf">Court
of Appeals</a>
<a href="/KSCourts/media/KsCourts/Opinions/125231.pdf?ext=.pdf">Court of Appeals</a>
</td>
<td>
<a href="/KSCourts/media/KsCourts/Opinions/125231.pdf?ext=.pdf">Unpublished</a>
Expand Down

0 comments on commit 30f7486

Please sign in to comment.