Skip to content

Commit

Permalink
Merge pull request kelvinxuande#4 from patrickcnkm/master
Browse files Browse the repository at this point in the history
Fix 2 issues ( invalid literal and assumption invalid)
  • Loading branch information
kelvinxuande authored Apr 28, 2022
2 parents 325e460 + f404c9c commit 87903d6
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions src/packages/page.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,15 @@ def extract_maximums(base_url):
page_soup,_ = requestAndParse(base_url)

tmp_match_1 = [item for item in page_soup.find_all("p") if "data-test" in item.attrs][0]
tmp_match_2 = [item for item in page_soup.find_all("div") if "data-test" in item.attrs][-1]
# Fixed the issue of the change of offset of item.attrs from [-1] to [-2] for pages
tmp_match_2 = [item for item in page_soup.find_all("div") if "data-test" in item.attrs][-2]

maxJobs_raw = tmp_match_1.get_text() # e.g. 7,764 Jobs
maxPages_raw = tmp_match_2.get_text() # e.g. Page 1 of 30

try:
assert "Jobs" in maxJobs_raw
# fixied the issue of "Assumptions invalid" given "Jobs" was changed to "jobs"
assert "jobs" in maxJobs_raw
assert "Page" in maxPages_raw
except Exception as e:
print(e)
Expand All @@ -28,6 +31,8 @@ def extract_maximums(base_url):
maxJobs = re.sub(r"\D", "", maxJobs_raw)
maxPages = re.sub(r"\D", "", maxPages_raw)[1:]



return(int(maxJobs), int(maxPages))


Expand Down

0 comments on commit 87903d6

Please sign in to comment.