tweet_text_parserAdds tweet entities to a tweets text in HTML | |
Download |
tweet_text_parser Ranking & Summary
Advertisement
- License:
- Freeware
- Price:
- FREE
- Publisher Name:
- Sym Roe
- Publisher web site:
- https://github.com/symroe/
tweet_text_parser Tags
tweet_text_parser Description
tweet_text_parser takes the JSON returned from Twitter's API and converts the tweet text in to HTML using the entities from the API, rather than trying to parse the text manually.Basic usagetweet = { "text" : "Some tweet", "entities" { #See the API example https://dev.twitter.com/docs/tweet-entities }}t = TweetTextParser(tweet)parsed_tweet = t.parse_all()parsed_tweetNote, the whole tweet is returned, with an additional key called html.Alternatively, a list of tweets can be passed, and each one will have an HTML key added to it.TemplatesIf you'd like to change the HTML output of the tweet, you can use pythons string.Template to edit them. At the moment, only the first half of the replacement is templated, as the second half is always "" by default.There are 4 templates that correspond to the different types of entity:- media_template- hashtags_template- user_mentions_template- url_templateTo changes a template:from string import Templatet = TweetTextParser(tweet)t.media_template = Template("""""")parsed_tweet = t.parse_all()parsed_tweetProduct's homepage
tweet_text_parser Related Software