This commit is contained in:
Mylloon 2021-08-27 00:25:01 +02:00
parent 05f11f06d9
commit 049b78a8f0

View file

@ -51,7 +51,7 @@ class Scraper:
return topics, self.getInfos(session, topics) return topics, self.getInfos(session, topics)
def parse(self, htmlPage: str) -> list[dict]: def parse(self, htmlPage: str) -> list[dict]:
"""Parse HTML reponse to a clean list""" """Parse HTML reponse to a clean list."""
if "No suitable matches were found." in htmlPage: if "No suitable matches were found." in htmlPage:
return [] return []
elements = htmlPage.split("<tr>\n<td>")[1:] elements = htmlPage.split("<tr>\n<td>")[1:]
@ -81,7 +81,7 @@ class Scraper:
return elements return elements
def getInfos(self, session: CloudScraper, elements: list) -> list: def getInfos(self, session: CloudScraper, elements: list) -> list:
"""Go to the first n pages and get a lot of infos""" """Go to the first n pages and get a lot of infos."""
size = len(elements) size = len(elements)
if size == 0: if size == 0:
return [] return []
@ -103,7 +103,7 @@ class Scraper:
return results return results
def parsingInfos(self, elements: list) -> list[dict]: def parsingInfos(self, elements: list) -> list[dict]:
"""Parse infos from the page of the app""" """Parse infos from the page of the app."""
for i in range(0, len(elements)): for i in range(0, len(elements)):
elements[i] = elements[i].text elements[i] = elements[i].text
if "Download Instructions" not in elements[i]: if "Download Instructions" not in elements[i]:
@ -131,7 +131,7 @@ class Scraper:
return elements return elements
def prettyPrint(self, topics: tuple[list[dict], list[dict]]) -> list: def prettyPrint(self, topics: tuple[list[dict], list[dict]]) -> list:
"""Show a pretty message with all the specialized infos""" """Show a pretty message with all the specialized infos."""
topics, topicsInfos = topics topics, topicsInfos = topics
if len(topics) == 0: if len(topics) == 0:
return [] return []