34 lines
986 B
Python
34 lines
986 B
Python
import requests
|
|
from lxml import html
|
|
|
|
# Adres URL strony do pobrania
|
|
url = 'https://papermodels.pl/forum-13.html'
|
|
|
|
# Pobranie zawartości strony
|
|
response = requests.get(url)
|
|
response.raise_for_status() # Sprawdza, czy żądanie zakończyło się sukcesem
|
|
|
|
# Parsowanie zawartości HTML
|
|
tree = html.fromstring(response.content)
|
|
|
|
# Wyszukiwanie linków do wątków
|
|
# Wyszukujemy linki, które zawierają "thread-" w href
|
|
thread_links = tree.xpath('//*[@id="content"]//table//a[contains(@href, "thread-")]/@href')
|
|
|
|
# Usunięcie duplikatów, linków względnych oraz filtracja
|
|
base_url = 'https://papermodels.pl'
|
|
filtered_links = set()
|
|
|
|
for link in thread_links:
|
|
# Konwertowanie linków względnych na pełne URL
|
|
if link.startswith('/'):
|
|
link = base_url + link
|
|
|
|
# Filtracja linków
|
|
if 'lastpost' not in link and 'newpost' not in link:
|
|
filtered_links.add(link)
|
|
|
|
# Wyświetlenie pełnych adresów URL wątków
|
|
for link in filtered_links:
|
|
print(link)
|