I want my Telegram bot to send a URL to a channel. However, the url contains the "&" character which cuts the message that it's trying to send short. The Telegram API documentation says I need to use & amp; (without the space) to replace & but either I don't understand something or it doesn't work.
Here's what I'm doing:
requests.get("https://api.telegram.org/"+botID+"/sendMessage?chat_id="+chatid+"&text="+movieSearch+"&parse_mode=HTML")
And movieSearch is:
movieSearch = ("https://www.imdb.com/search/title?release_date="+year+"-01-01,2018-12-31&user_rating="+score+",&genres="+genres)
You can see that in movieSearch after the release_date there is &user_rating=... and so on. However, the bot will only send the URL until just before that & character (so until "2018-12-31").
I've tried replacing & with & amp; but it still won't send the whole URL. I've tried without the parse_mode=HTML but it didn't work either.
,
next to the&genres
.. get rid of the comma – UnknitmovieSearch
into the request.. – Unknit&
– Grahamgrahame&
, it does the same as with & – Faydra%26amp;
instead. This is because you are not letting the requests library escape it for you. – Grahamgrahame%26amp;
worked. Had no idea the requests library had an effect, thank you! – Faydra