mirror of
https://github.com/KeksPirates/SoftwareManager.git
synced 2026-08-03 17:39:42 +02:00
now shows the post title instead of the link
fetching post titles is still quite slow but it will be fixed
This commit is contained in:
@@ -1,6 +1,5 @@
|
|||||||
import requests
|
import requests
|
||||||
from bs4 import BeautifulSoup
|
from bs4 import BeautifulSoup
|
||||||
import curses
|
|
||||||
|
|
||||||
search = input("Enter the name of the program you want to search for: ")
|
search = input("Enter the name of the program you want to search for: ")
|
||||||
url = "https://uztracker.net/tracker.php?nm=" # placeholder url for now
|
url = "https://uztracker.net/tracker.php?nm=" # placeholder url for now
|
||||||
@@ -18,11 +17,13 @@ def scrape_uztracker():
|
|||||||
for link in links:
|
for link in links:
|
||||||
if link.has_attr('href'):
|
if link.has_attr('href'):
|
||||||
href = link['href']
|
href = link['href']
|
||||||
|
global post_url
|
||||||
post_url = f"https:{href}" if isinstance(href, str) and href.startswith("//") else href
|
post_url = f"https:{href}" if isinstance(href, str) and href.startswith("//") else href
|
||||||
if isinstance(post_url, str) and post_url.startswith("./viewtopic.php?t="):
|
if isinstance(post_url, str) and post_url.startswith("./viewtopic.php?t="):
|
||||||
post_url = f"https://uztracker.net{post_url[1:]}"
|
post_url = f"https://uztracker.net{post_url[1:]}"
|
||||||
print(f"Found post link: {post_url}")
|
# print(f"Found post link: {post_url}")
|
||||||
found_links = True
|
found_links = True
|
||||||
|
get_post_title(post_url)
|
||||||
if not found_links:
|
if not found_links:
|
||||||
print(f"No post link found on {search_url}")
|
print(f"No post link found on {search_url}")
|
||||||
return soup
|
return soup
|
||||||
@@ -30,7 +31,9 @@ def scrape_uztracker():
|
|||||||
print(f"Failed to fetch {search_url}: {e}")
|
print(f"Failed to fetch {search_url}: {e}")
|
||||||
return None
|
return None
|
||||||
|
|
||||||
def get_post_title(soup):
|
def get_post_title(post_url):
|
||||||
|
response = requests.get(post_url)
|
||||||
|
soup = BeautifulSoup(response.text, 'html.parser')
|
||||||
maintitle = soup.find(class_='tt-text')
|
maintitle = soup.find(class_='tt-text')
|
||||||
if maintitle:
|
if maintitle:
|
||||||
print("Program found:", maintitle.text)
|
print("Program found:", maintitle.text)
|
||||||
@@ -56,11 +59,8 @@ def get_magnet_link(post_url="https://uztracker.net/viewtopic.php?t=23897"):
|
|||||||
# and - if x exists, THEN check the next part
|
# and - if x exists, THEN check the next part
|
||||||
# x.startswith('magnet:') - does x start with "magnet:"?
|
# x.startswith('magnet:') - does x start with "magnet:"?
|
||||||
|
|
||||||
post_url = scrape_uztracker
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
soup = scrape_uztracker()
|
soup = scrape_uztracker()
|
||||||
if soup:
|
if soup:
|
||||||
get_post_title(soup)
|
|
||||||
get_magnet_link()
|
get_magnet_link()
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user