S
S
Sergey Afanasiev2020-06-24 22:23:58
Python
Sergey Afanasiev, 2020-06-24 22:23:58

The bot does not send a message in the form of a dictionary, what should I do?

Hello everyone, I wanted to make a bot for myself that parses various data from the site, and sends information in the form of a dictionary, a message in a telegram, but for some reason it only sends the 'Name', don't yell too much, I'm new to python :)

r = requests.get('http://baskino.me/films/fantasticheskie/')
soup = BS(r.content, 'html.parser')

def fantasic_message(message):
    items = soup.find_all('div', class_='shortpost')
    movie = []
    for item in items:
        movie.append({
            'Название': item.find('div', class_='posttitle').get_text(strip=True),
            'Ссылка': item.find('a').get('href'),
            'Рейтинг': item.find('li', class_='current-rating').get_text(),
            'Дата': item.find('div', class_='rinline').get_text()
        })
    bot.send_message(message.chat.id, movie, parse_mode='html')

Answer the question

In order to leave comments, you need to log in

2 answer(s)
S
soremix, 2020-06-24
@keksss17

Try sending it as a string.
str(movie)

P
p1ugg, 2020-06-24
@p1ugg

Try to output movie[1:-1].

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question