Answer the question
In order to leave comments, you need to log in
How to display text when parsing?
How do I output "word" if it's not in "Class"? What should I enter in the "Class" column? Sorry if this is a dumb question, I've only been programming for 4 days..
soup = BeautifulSoup(resp, 'html.parser')
divs = soup.find('div', class_='result-shield-container tlid-copy-target')
appeals = soup.find_all('span', class_='tlid-translation translation')
bot.send_message(message.chat.id, appeals.get_text(''))
Answer the question
In order to leave comments, you need to log in
bot.send_message(message.chat.id, appeals[0].text) should help if memory serves
hoogierain
# если такой класс встречается в html-коде только ОДИН раз, то код такой:
soup = BeautifulSoup(resp, 'html.parser')
appeals = soup.find('span', {'class': 'tlid-translation translation'}).get_text().strip()
bot.send_message(message.chat.id, appeals)
# если НЕСКОЛЬКО раз, то код такой:
soup = BeautifulSoup(resp, 'html.parser')
appeals = [s.get_text().strip() for s in soup.find_all('span', {'class': 'tlid-translation translation'})]
for app in appeals:
bot.send_message(message.chat.id, app)
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question