Skip to content

Commit

Permalink
Killed off final ToDo.
Browse files Browse the repository at this point in the history
  • Loading branch information
euanwm committed Mar 13, 2022
1 parent 8459f7e commit a0f5450
Showing 1 changed file with 17 additions and 1 deletion.
18 changes: 17 additions & 1 deletion sport80/helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
from bs4 import BeautifulSoup
from requests import Response

from sport80.pages_enum import EndPoint


def resolve_to_ip(url: str) -> str:
""" Returns IP address of the subdomain """
Expand Down Expand Up @@ -58,6 +60,7 @@ def recursive_anti_nester(nested_list: list) -> list:

class AntiNester(list):
""" Being simultaneously lazy and extra """

def __init__(self):
super().__init__()
self.flat_list: list = []
Expand Down Expand Up @@ -98,7 +101,10 @@ def strip_table_body(table):
cells.append(tbl_hdr.text.strip())
else:
for tbl_dat in tds:
if len(tbl_dat.find_all('i')) == 1:
links = tbl_dat.find_all(href=True)
if len(links) == 1:
cells.append(strip_report_id(links[0]['href']))
elif len(tbl_dat.find_all('i')) == 1:
strip_it = str(tbl_dat.find_all('i'))
if "data-id-resource" in strip_it:
re_search = re.search(r'\d+', strip_it)
Expand All @@ -109,3 +115,13 @@ def strip_table_body(table):
cells.append(tbl_dat.text.strip())
rows.append(cells)
return rows


def strip_report_id(url: str) -> str:
""" This could probably be done a bit neater but IDC currently """
url_endpoint = EndPoint.START_LIST.value
if url_endpoint in url:
extracted_url = re.search(url_endpoint, url)
return url[extracted_url.regs[0][1]::]
else:
return url

0 comments on commit a0f5450

Please sign in to comment.