46 lines
1.3 KiB
Python
46 lines
1.3 KiB
Python
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)
|
|
|