diff --git a/main.py b/main.py new file mode 100644 index 0000000..5c32eea --- /dev/null +++ b/main.py @@ -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) + diff --git a/requirements.txt b/requirements.txt new file mode 100644 index 0000000..a98ae43 --- /dev/null +++ b/requirements.txt @@ -0,0 +1,2 @@ +requests +beautifulsoup4 \ No newline at end of file