Hello,
I’m new to the community and I’m just trying my first Twitter program that will tweet out some scraped data that I collect from an HTML site. I have this data saved in a MongoDB database. I’m using the Python-Twitter library for this project. I’m trying to iterate through some MongoDB documents and post them in a certain format. Here goes:
#From the MongoDB Document
url = bill['url']
#Cap the name at 91 characters
if (len(name) > 91):
name = name[0:88]
name = name + "..."
#That's 25 chars + 23 for a shortened URL = 91 left for name
to_tweet = "#DonaldTrump has signed: " + name + url
Okay, this will tweet some bills the Prez has signed. As you can see, I should have exactly 140 characters at most. This is assuming that all URL’s are shortened/expanded to 23 characters. However, I’m getting an error that I’m over the 140 limit. I’m just not understanding why that is. Here is a print statement of to_tweet:
#DonaldTrump has signed: S.84 - A bill to provide for an exception to a limitation against appointment of persons...https://www.whitehouse.gov/legislation/s84-bill-provide-exception-limitation-against-appointment-persons-secretary-defense
A direct copy and paste of that puts me one character short of the limit in my web browser, and indeed, this exact same tweet works in a different python script. So does anyone have any advice as to how to solve this issue? Am I missing something so simple that I’ll feel really dumb? Any help would be greatly appreciated and thanks for having me in the community!