added search function to scraper

This commit is contained in:
KeksNino
2024-12-17 16:56:10 +01:00
parent ef7150cf76
commit 8d6524e086
+21 -4
View File
@@ -19,14 +19,31 @@ if response.status_code == 200:
continue continue
games = soup.find_all("li") games = soup.find_all("li")
if games: game_titles = [game.text.strip() for game in games]
if game_titles:
print("Games Found:") print("Games Found:")
for game in games: for title in game_titles:
print(game.text.strip()) pass
else: else:
print("No game titles found. Report this on Github.") print("No game titles found. Report this on Github.")
else: else:
print(f"Failed to retrieve the page. Status code: {response.status_code}") print(f"Failed to retrieve the page. Status code: {response.status_code}")
def search_games(query, game_titles):
results = [title for title in game_titles if query.lower() in title.lower()]
return results
search_query = input("Enter a game title to search: ")
search_results = search_games(search_query, game_titles)
if search_results:
print("Search Results:")
for result in search_results:
print(result)
else:
print("No matching game titles found.")
# url = "https://cs.rin.ru/" # url = "https://cs.rin.ru/"
# url = "https://gamesdrive.net/" # url = "https://gamesdrive.net/"
# url = "https://gog-games.to/" # url = "https://gog-games.to/"
@@ -51,7 +68,7 @@ else:
# url = "https://www.cg-gamespc.com/" # url = "https://www.cg-gamespc.com/"
# url = "https://gamepcfull.com/" # url = "https://gamepcfull.com/"
# # Repacks/Torrents # Repacks/Torrents
# url = "https://www.kaoskrew.org/" # url = "https://www.kaoskrew.org/"
# url = "https://fitgirl-repacks.site/" # url = "https://fitgirl-repacks.site/"
# url = "https://m4ckd0ge-repacks.site/" # url = "https://m4ckd0ge-repacks.site/"