Добавил парсинг kinoneo
This commit is contained in:
parent
da381b9525
commit
a46abb39f1
45
main.py
Normal file
45
main.py
Normal 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
2
requirements.txt
Normal file
@ -0,0 +1,2 @@
|
||||
requests
|
||||
beautifulsoup4
|
Loading…
x
Reference in New Issue
Block a user