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 7647711
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T10:31:52+00:00 2026-05-31T10:31:52+00:00

I am trying to use twitter search web service in python. I want to

  • 0

I am trying to use twitter search web service in python. I want to call a web service like:

http://search.twitter.com/search.json?q=blue%20angels&rpp=5&include_entities=true&result_type=mixed

from my python program.

Can anybody tell me

  1. how to use xmlhttprequst object in python

  2. how to pass parameters to it, and

  3. how to get the data in dictionary.

Here is my try:

import urllib
import sys
url = "http://search.twitter.com/search.json?q=blue%20angels&rpp=5&include_entities=true&result_type=mixed"
urlobj = urllib.urlopen(url)
data = urlobj.read()
print data

Thanks.

  • 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-05-31T10:31:54+00:00Added an answer on May 31, 2026 at 10:31 am

    You don’t need “asynchronous httprequest” to use twitter search api:

    import json
    import urllib
    import urllib2
    
    # make query
    query = urllib.urlencode(dict(q="blue angel", rpp=5, include_entities=1,
                                  result_type="mixed"))  
    # make request
    resp = urllib2.urlopen("http://search.twitter.com/search.json?" + query)
    
    # make dictionary (parse json response)
    d = json.load(resp)
    

    There are probably several libraries that provide a nice OO interface around these http requests.

    To make multiple requests concurrently you could use gevent:

    import gevent
    import gevent.monkey; gevent.monkey.patch_all() # patch stdlib
    
    import json
    import urllib
    import urllib2
    
    def f(querystr):
        query = urllib.urlencode(dict(q=querystr, rpp=5, include_entities=1,
                                      result_type="mixed"))
        resp = urllib2.urlopen("http://search.twitter.com/search.json?" + query)
        d = json.load(resp)
        print('number of results %d' % (len(d['results']),))
    
    jobs = [gevent.spawn(f, q) for q in ['blue angel', 'another query']]
    gevent.joinall(jobs) # wait for completion
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to find people via Twitter API. I use urls like this: https://api.twitter.com/1/users/search.json?q=some@email.com
I am trying to use this railscast episode to provide authentication via twitter http://railscasts.com/episodes/235-omniauth-part-1
I'm trying use mod_rewrite to rewrite URLs from the following: http://www.site.com/one-two-file.php to http://www.site.com/one/two/file.php The
I'm trying to use the Zend twitter service in codeigniter. I have used the
I'm trying to use the JSON library to consume twitter information from the get
I am trying to use Tweetsharp to do a search on twitter for specific
I've been trying to use twitter4J and this tut ( http://java-tutorial.ch/framework/twitter-with-java-tutorial ) in attempting
I'm using the twitter gem located here... http://rubydoc.info/gems/twitter/2.0.2 I'm trying to use a method
I am trying to get the JSON data from a Twitter search request such
I'm trying to use twitter bootstrap to create Facebook like tooltip layout. I would

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.