import requests
from bs4 import BeautifulSoup
def parse():
headers = {
"user-agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.75 Safari/537.36"
}
url = "https://tv.mail.ru/moskva/"
r = requests.get(url=url, headers=headers)
soup = BeautifulSoup(r.text, 'lxml')
program = soup.find_all('div', class_="p-channels__item")
for program in program:
program_title = program.find("a", class_="p-channels__item__info__title__link").text.strip()#название канала
section = program_title.split("live")[0]
items = program.find("div", class_="p-programms").text.strip()#Программа
print(f"{section} | {items}")
parse()
#Первый канал | 22:00Шифр23:35Ван Гог. На пороге вечности01:35Наедине со #всеми03:50Россия от края до края05:35Хиромант
items = program.find("div", class_="p-programms").strings
joined_items = "\n".join(items)
print(f"{section} | {joined_items}")
for program in program: