import requests from lxml import html # Adres URL strony do pobrania url = 'https://sklej-model.pl/pl/content/13-nowosci' # 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) # Wybór elementów za pomocą XPath elements = tree.xpath('//*[@id="center_column"]') # Lista do przechowywania linków all_links = [] # Sprawdzenie, czy znaleziono jakiekolwiek elementy if elements: for element in elements: # Wyodrębnienie linków z wnętrza wybranego elementu links = element.xpath('.//a/@href') all_links.extend(links) # Usunięcie duplikatów unique_links = set(all_links) # Filtracja linków filtered_links = [ link for link in unique_links if 'laserowo' not in link and 'author' not in link and 'category' not in link and 'page' not in link ] # Wyświetlenie przefiltrowanych linków for link in filtered_links: print(link)