I have a typical code written that I was using to listen to Twitter’s Streaming API, which worked perfectly until the other day. The only thing that has changed is that I changed the password to my computer. Here is the code I’m using:
import urllib2
proxy = urllib2.ProxyHandler({‘http’: ‘http://username:password@1proxy:port’})
auth = urllib2.HTTPBasicAuthHandler()
opener = urllib2.build_opener(proxy, auth, urllib2.HTTPHandler)
urllib2.install_opener(opener)
import tweepy, json, datetime
consumerKey = 'xxxx’
consumerSecret = 'xxxx’
accessKey = 'xxxx’
accessSecret = ‘xxxx’
search = raw_input('Please enter your search term(s): ')
class Listener(tweepy.StreamListener):
def on_data(self, data):
decoded = json.loads(data)
params = (decoded[‘user’][‘screen_name’]
, decoded[‘text’].encode(‘ascii’, ‘ignore’)
, datetime.datetime.utcfromtimestamp((float(decoded[‘timestamp_ms’]))/1000).strftime(’%Y-%m-%d %H:%M:%S’))
print ‘@%s: %s %s’ %(params)
print ''
print ''
return True
def on_error(self, status):
print status
auth = tweepy.OAuthHandler(consumerKey, consumerSecret)
auth.set_access_token(accessKey, accessSecret)
stream = tweepy.Stream(auth, Listener())
stream.filter(track=[search])
I updated the password in my source code, but it still throws error 407 when it tries to get the URL. Has anything changed with Twitter’s API? Or is there some other reason my proxy would refuse to connect now? Thanks in advance!