This is the method I used in the project, which takes the text attribute of the tweet object and returns the text with both hashtags and user_mentions associated with the corresponding twitter pages, in accordance with the latest recommendations for displaying twitter.
def link_tweet(tweet): """ This method takes the text attribute from a tweet object and returns it with user_mentions and hashtags linked """ tweet = re.sub(r'(\A|\s)@(\w+)', r'\1@<a href="http://www.twitter.com/\2">\2</a>', str(tweet)) return re.sub(r'(\A|\s)#(\w+)', r'\1#<a href="http://search.twitter.com/search?q=%23\2">\2</a>', str(tweet))
Once you call this method, you can pass the parameter my_tweet [x] .text. Hope this will be helpful.
Chris Clouten Feb 20 '13 at 21:00 2013-02-20 21:00
source share