Добавил парсинг kinoneo

This commit is contained in:
Sergey Karmanov 2023-08-25 02:29:23 +03:00
parent da381b9525
commit a46abb39f1
Signed by: serega404
GPG Key ID: B6AD49C8C835460C
2 changed files with 47 additions and 0 deletions

45
main.py Normal file
View File

@ -0,0 +1,45 @@
import requests, json, os
from bs4 import BeautifulSoup
import json
# Config
API_URL = os.environ.get('API_URL', 'https://address.ru/v1/parser/UpdateFilms')
if API_URL == 'API_URL':
print("API_URL is not set")
exit()
# Get data
req = requests.get("https://www.kinoneo.ru/schedule")
if (req.status_code != 200):
print("Отвал кинонео: " + str(req.status_code))
soup = BeautifulSoup(req.content, "html.parser")
elements = []
for tag in soup.find_all("div", {"class": "schedule-row"}):
if (tag.text.find("ПУШКИНСКАЯ КАРТА") != -1):
# print(tag.find("span", class_="title-xs"))
genre = " ".join(tag.find_all("span")[1].text.replace(' ', "").replace('\n', '').split())
title = tag.find("span", class_="title-xs")
url = "https://www.kinoneo.ru" + title.parent.get('href')
imamgeurl = "https://www.kinoneo.ru" + tag.find("img").get('src')
json = {
"city": "Таганрог",
"cinema": "КиноНЕО",
"filmName": title.text,
"genre": genre,
"url": url,
"imageUrl": imamgeurl
}
elements.append(json)
request = requests.post(API_URL, json = elements)
if (request.status_code != 200):
print("Не удалось отправить запрос на сервер: " + str(request.status_code) + " " + request.text)

2
requirements.txt Normal file
View File

@ -0,0 +1,2 @@
requests
beautifulsoup4