i'm a begginer programmer and i'm having troubles with my twitter bot. The idea of the bot is tweet an daily verse of bible everyday, and that's what I got so far:
import tweepy
import requests
api = tweepy.Client(
consumer_key='',
consumer_secret='',
access_token='-',
access_token_secret='',
)
response = requests.get("https://www.biblegateway.com/votd/get/?format=json&version=NVI-PT")
verse_of_the_day = response.json()["votd"]["text"]
try:
tweet=api.create_tweet(text=("Aqui está o versículo do dia: \n") verse_of_the_day)
print(tweet)
except:
print("something is wrong")
the problem is that some characters appear as HTML entity and not as the "character itself" and what I hope is to fix these characters that are in html entity
CodePudding user response:
You can unescape the HTML entities using the html.unescape()
function
import tweepy
import requests
import html
api = tweepy.Client(
consumer_key='',
consumer_secret='',
access_token='-',
access_token_secret='',
)
response = requests.get("https://www.biblegateway.com/votd/get/?format=json&version=NVI-PT")
verse_of_the_day = html.unescape(response.json()["votd"]["text"]) #unescapes the string
try:
tweet=api.create_tweet(text=("Aqui está o versículo do dia: \n") verse_of_the_day)
print(tweet)
except:
print("something is wrong")