mirror of
https://github.com/KeksPirates/SoftwareManager.git
synced 2026-08-04 09:59:41 +02:00
search uztracker software
.startswith filter on line 22 is broken
This commit is contained in:
@@ -1,10 +1,34 @@
|
|||||||
import requests
|
import requests
|
||||||
from bs4 import BeautifulSoup
|
from bs4 import BeautifulSoup
|
||||||
|
|
||||||
url = "https://uztracker.net/viewtopic.php?t=23897" # placeholder url for now
|
search = input("Enter the name of the program you want to search for: ")
|
||||||
|
url = "https://uztracker.net/tracker.php?nm=" # placeholder url for now
|
||||||
response = requests.get(url) # get da content from da url
|
response = requests.get(url) # get da content from da url
|
||||||
soup = BeautifulSoup(response.content, 'html.parser') # create bs object
|
soup = BeautifulSoup(response.content, 'html.parser') # create bs object
|
||||||
|
|
||||||
|
def scrape_uztracker():
|
||||||
|
search_url = url + search
|
||||||
|
print(search_url)
|
||||||
|
try:
|
||||||
|
response = requests.get(search_url)
|
||||||
|
response.raise_for_status()
|
||||||
|
soup = BeautifulSoup(response.text, 'html.parser')
|
||||||
|
links = soup.find_all('a')
|
||||||
|
found_links = False
|
||||||
|
for link in links:
|
||||||
|
if link.has_attr('href'):
|
||||||
|
href = link['href']
|
||||||
|
post_url = f"https:{href}" if isinstance(href, str) and href.startswith("//") else href
|
||||||
|
if isinstance(post_url, str) and post_url.startswith("https://uztracker.net/viewtopic.php?t="): # please figure out why this .startswith filter is not working
|
||||||
|
print(f"Found post link: {post_url}")
|
||||||
|
found_links = True
|
||||||
|
if not found_links:
|
||||||
|
print(f"No post link found on {search_url}")
|
||||||
|
return soup
|
||||||
|
except requests.RequestException as e:
|
||||||
|
print(f"Failed to fetch {search_url}: {e}")
|
||||||
|
return None
|
||||||
|
|
||||||
def get_post_title():
|
def get_post_title():
|
||||||
maintitle = soup.find(class_='tt-text')
|
maintitle = soup.find(class_='tt-text')
|
||||||
if maintitle:
|
if maintitle:
|
||||||
@@ -26,7 +50,10 @@ def get_magnet_link():
|
|||||||
# 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:"?
|
||||||
|
|
||||||
|
if __name__ == "__main__":
|
||||||
|
soup = scrape_uztracker()
|
||||||
|
|
||||||
if response.status_code == 200:
|
if response.status_code == 200:
|
||||||
get_post_title()
|
get_post_title()
|
||||||
get_magnet_link()
|
get_magnet_link()
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user