From a46abb39f18fca9ff4bf317c177c23eb3a8c38cd Mon Sep 17 00:00:00 2001 From: Sergey Karmanov Date: Fri, 25 Aug 2023 02:29:23 +0300 Subject: [PATCH] =?UTF-8?q?=D0=94=D0=BE=D0=B1=D0=B0=D0=B2=D0=B8=D0=BB=20?= =?UTF-8?q?=D0=BF=D0=B0=D1=80=D1=81=D0=B8=D0=BD=D0=B3=20kinoneo?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- main.py | 45 +++++++++++++++++++++++++++++++++++++++++++++ requirements.txt | 2 ++ 2 files changed, 47 insertions(+) create mode 100644 main.py create mode 100644 requirements.txt 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