62 lines
1.8 KiB
Python
62 lines
1.8 KiB
Python
import requests
|
|
from bs4 import BeautifulSoup
|
|
|
|
|
|
# job_elements = results.find_all("div", class_="calCard-container")
|
|
|
|
|
|
# Nietypowe święta
|
|
|
|
|
|
|
|
# cytat na dzień
|
|
|
|
|
|
|
|
#print(swieto)
|
|
|
|
from datetime import datetime, timedelta
|
|
|
|
# Definicja nazw miesięcy bez polskich znaków
|
|
months = ["stycznia", "lutego", "marca", "kwietnia", "maja", "czerwca",
|
|
"lipca", "sierpnia", "wrzesnia", "pazdziernika", "listopada", "grudnia"]
|
|
|
|
# Ustal datę początkową (1 stycznia bieżącego roku)
|
|
start_date = datetime(datetime.now().year, 1, 1)
|
|
|
|
# Ustal datę końcową (31 marca bieżącego roku)
|
|
end_date = datetime(datetime.now().year, 1, 31)
|
|
|
|
# Inicjalizacja daty do wyświetlania
|
|
current_date = start_date
|
|
|
|
# Pętla wyświetlająca daty od początku roku do końca marca z nazwą miesiąca bez polskich znaków
|
|
while current_date <= end_date:
|
|
miesiac = current_date.strftime(f'{months[current_date.month - 1]}')
|
|
dzien = current_date.day
|
|
date = current_date.strftime(f'%Y-%m-%d')
|
|
kalbi = "https://www.kalbi.pl/" + str(dzien) +"-"+miesiac
|
|
print(kalbi)
|
|
page = requests.get(kalbi)
|
|
soup = BeautifulSoup(page.content, "html.parser")
|
|
results = soup.find_all('section', class_='calCard-ententa')
|
|
for result in results:
|
|
links = result.find_all("a")
|
|
for link in links:
|
|
link_url = link["title"]
|
|
print(link_url)
|
|
cytaty = soup.find_all('section', class_='calCard-quotes')
|
|
for cytat in cytaty:
|
|
cytat_tekst = cytat.find('i')
|
|
print(cytat_tekst)
|
|
swieta = soup.find_all('div', class_='calCard-fete')
|
|
for swieto in swieta:
|
|
nazwy = swieto.find_all('a')
|
|
for nazwa in nazwy:
|
|
tekst = nazwa.text.strip()
|
|
print(tekst)
|
|
|
|
|
|
# end of program
|
|
current_date += timedelta(days=1)
|