mirror of
https://github.com/KeksPirates/SoftwareManager.git
synced 2026-08-04 17:59:43 +02:00
a fuzzyfind demo works, use python -m core.interface.utils.fzhelper
This commit is contained in:
@@ -4,21 +4,40 @@ import requests
|
||||
import re
|
||||
#from core.utils.general.logs import consoleLog
|
||||
|
||||
def scrape_steamrip_links():
|
||||
url = f"https://steamrip.com/games-list-page/"
|
||||
response = requests.get(url)
|
||||
soup = BeautifulSoup(response.text, "html.parser")
|
||||
def scrape_steamrip_links(text = None):
|
||||
if text is None:
|
||||
url = f"https://steamrip.com/games-list-page/"
|
||||
response = requests.get(url)
|
||||
text = response.text
|
||||
|
||||
soup = BeautifulSoup(text, "html.parser")
|
||||
games = soup.find_all("li", class_="az-list-item")
|
||||
|
||||
if len(games) == 0:
|
||||
return []
|
||||
|
||||
links = []
|
||||
for gamehtml in games:
|
||||
for i, gamehtml in enumerate(games):
|
||||
if i == 0: print(gamehtml)
|
||||
link = gamehtml.find("a", href=lambda x: x and x.startswith("/"))
|
||||
links += re.findall('(?<=href=")[^"]*', link.__str__())
|
||||
|
||||
return links
|
||||
|
||||
# construct the list[dict[str,str]]
|
||||
|
||||
ret = []
|
||||
|
||||
for link in links:
|
||||
ret.append({"name" : link})
|
||||
|
||||
return ret
|
||||
|
||||
def offline_scrape_steamrip_links():
|
||||
text = ""
|
||||
with open("example.html", encoding = "utf-8") as f:
|
||||
text=f.read()
|
||||
|
||||
return scrape_steamrip_links(text)
|
||||
|
||||
if __name__ == "__main__":
|
||||
print(scrape_steamrip_links())
|
||||
print(offline_scrape_steamrip_links())
|
||||
Reference in New Issue
Block a user