CDT CDT - 1 year ago 147
Python Question

Accessing twitter using tornado.httpclient using proxy

I want to access Twitter from the terminal using


But Twitter is firewalled in my country. How can I access it through proxy?

Are there any other options?

Answer Source

The official documentation for tornado.httpclient contains examples how to use proxy.

You will need curl backend for proxy support. So install the prerequisites. Here's how to do that for Ubuntu:

$ sudo apt-get install libcurl-dev librtmp-dev 
$ pip install tornado pycurl

Then try this code:

from tornado import httpclient, ioloop

config = {
    'proxy_port': 3128


def handle_request(response):
    if response.error:
        print "Error:", response.error
        print response.body

http_client = httpclient.AsyncHTTPClient()
    handle_request, **config)
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download