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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T07:46:31+00:00 2026-06-14T07:46:31+00:00

I am learning Python, and I want to start using Twitter’s streaming API. I

  • 0

I am learning Python, and I want to start using Twitter’s streaming API. I know how to build a very basic application that reads the contents of a page using urllib2 and have done this successfully in the past. However, the secure connection https:// that this particular Twitter streaming API requires doesn’t appear to work with urllib2.

I have tried to fetch the JSON from the following link: https://stream.twitter.com/1.1/statuses/filter.json?locations=-122.75,36.8,-121.75,37.8

By writing the following:

import urllib2
url = "https://stream.twitter.com/1.1/statuses/filter.json?locations=-122.75,36.8,-121.75,37.8"
print urllib2.urlopen(url).read()

The traceback, though, says I am not authorized; I presumed this is because of the HTTPS SSL connection, and research supported this. So I guess my question is what is the best way to go about getting the JSON from a link requiring such SSL connection? I also tried curl, but only get error 401 again.

Below is the traceback in its entirety.

Traceback (most recent call last): File “”, line 1, in
File
“/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/urllib2.py”,
line 126, in urlopen File
“/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/urllib2.py”,
line 400, in open File
“/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/urllib2.py”,
line 513, in http_response File
“/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/urllib2.py”,
line 438, in error File
“/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/urllib2.py”,
line 372, in _call_chain File
“/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/urllib2.py”,
line 521, in http_error_default urllib2.HTTPError: HTTP Error 401:
Unauthorized

Many thanks in advance.

  • 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-14T07:46:32+00:00Added an answer on June 14, 2026 at 7:46 am

    As others mention, you need to authorize. Here’s how to do it:

    See Twitter API with urllib2 in python

    import urllib2
    import base64
    
    request = urllib2.Request( 'https://stream.twitter.com...' )
    request.add_header( 'Authorization', 'Basic ' + base64.b64encode( username + ':' + password ) )
    response = urllib2.urlopen( request )
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want to learn server-side scripting. Since I know some Python, probably that would
Possible Duplicate: How to Start learning to create iphone apps I only know basic
I'm just learning how to do things, and want to start using some sort
I am learning OOP with python. I want to implement something like to display:
I'm learning Python, Django, Javascript and jQuery by trying to build a simple shopping
I just started using/learning Python and have some questions. I have a text file
I'm using PyWin32's win32process.CreateProcess to start up a GUI program that has functionality I
Right now, I'm learning Python and Javascript, and someone recently suggested to me that
I'm learning Python and decided to start familiarizing myself with the (defacto?) Python web
I want to start learning OpenGL but I don't really want to have to

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.