Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8114091
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T03:02:51+00:00 2026-06-06T03:02:51+00:00

I am using twython to connect to Twitter API and retrieve a query. Here

  • 0

I am using twython to connect to Twitter API and retrieve a query. Here is an example of what I get:

---START----

{u'next_page': u'?page=2&max_id=215397707'
....
: 215397707794219008L, u'page': 1}

----END----

What I am interested in is the actual tweet which starts like this:

u'text': u'@ilariargn devi fare un corso sul respiro! Sarebbero 7686879 euro, ci vieni? #perderetempo', u'from_user_name':

So everything between “u’text’: u'” and “u’from_user_name'”. I tried to get this information first with key and value because it is a dictionary. Does not work. Then I tried to convert the dictionary into a list and use a string search to get the position. Does not work either. How do I get this information?

I tried suggested solutions and received following messages:

tweet = json.loads(results)[u'text']
File "C:\Python27\lib\json\__init__.py", line 326, in loads
return _default_decoder.decode(s)
File "C:\Python27\lib\json\decoder.py", line 366, in decode
obj, end = self.raw_decode(s, idx=_w(s, 0).end())
TypeError: expected string or buffer

And for the second solution – if I write [t’text] I get a syntax error:

tweet = results[u'text']
KeyError: u'text'
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-06T03:02:53+00:00Added an answer on June 6, 2026 at 3:02 am

    Ok. After some trials I found the following solution to access the actual tweets:

    counter = 1
    for key, value in results.iteritems():
        if key == "results":
            svalue = str(value)
            while counter != -1:
                tweetposstart = svalue.find("u'text'",counter)
                tweetposend = svalue.find("u'from_user_name'",counter)
                if tweetposstart != -1:
                    tweet = svalue[tweetposstart:tweetposend]
                    print tweet
                    counter = counter + tweetposstart
                else:
                    counter = tweetposstart
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Using the HTML5 File API I can get the Binary String representation of a
I want to extract information from Twitter using Python. There is a page with
Using php/html, I want to retrieve email addresses (plus other information) from MySQL and
Using emacs on Ubuntu 11.10. I want to connect to a SQL Server database
Using WebViewBrush I can render web page content (it's screen shot) to e.g. Rectangle
using file_get_contents , I open an Internet URL and get the contents of this
Using the current request I can get the URL hostname with: HttpContext.Current.Request.Url.Host But -
Using the C# Facebook SDK 5.0.3 everything works fine whit the client.Get(/me). But when
Using Java, how can I extract all the links from a given web page?
Using C# and System.Data.SqlClient, is there a way to retrieve a list of parameters

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.