tweet_text_parser 0.1

Adds tweet entities to a tweets text in HTML
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 usage

tweet = {
 "text" : "Some tweet",
 "entities" {
 #See the API example https://dev.twitter.com/docs/tweet-entities
 }
}
t = TweetTextParser(tweet)
parsed_tweet = t.parse_all()[0]
parsed_tweet['html]


Note, 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.

Templates

If 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_template

To changes a template:

from string import Template
t = TweetTextParser(tweet)
t.media_template = Template("""""")

parsed_tweet = t.parse_all()[0]
parsed_tweet['html]

last updated on:
August 25th, 2012, 8:28 GMT
price:
FREE!
developed by:
Sym Roe
homepage:
github.com
license type:
Freeware 
category:
ROOT \ Internet \ HTTP (WWW)
tweet_text_parser
Download Button

In a hurry? Add it to your Download Basket!

user rating

UNRATED
0.0/5
 

0/5

Rate it!

Add your review!

SUBMIT