May 17, 2026, 11:40 PM
This commit is contained in:
@@ -0,0 +1,26 @@
|
||||
import requests
|
||||
from lxml import html
|
||||
|
||||
# Adres URL strony do pobrania
|
||||
url = 'https://www.answer.pl/' # Zmień na odpowiedni URL
|
||||
|
||||
# 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
|
||||
links = tree.xpath('//*[@id="blocknewproducts"]//a/@href')
|
||||
|
||||
# Usunięcie duplikatów, filtracja adresów zawierających '3_3' oraz 'carro-de-la-compra'
|
||||
unique_links = set(links) # Usunięcie duplikatów
|
||||
filtered_links = [
|
||||
link for link in unique_links
|
||||
if '3_3' not in link and 'carro-de-la-compra' not in link and 'akcesoria' not in link and 'kabiny' not in link and 'kola' not in link
|
||||
]
|
||||
|
||||
# Wyświetlenie przefiltrowanych linków
|
||||
for link in filtered_links:
|
||||
print(link)
|
||||
Reference in New Issue
Block a user