2
Sprachversion: python 2.7.11Tweepy StreamListener Connection
from tweepy.streaming import StreamListener
from tweepy import OAuthHandler
from tweepy import Stream
access_token = "****"
access_token_secret = "****"
consumer_key = "****"
consumer_secret = "****"
class StdOutListener(StreamListener):
def on_data(self, data):
print data
return True
def on_error(self, status):
print status
if __name__ == '__main__':
l = StdOutListener()
auth = OAuthHandler(consumer_key, consumer_secret)
auth.set_access_token(access_token, access_token_secret)
stream = Stream(auth, l)
stream.filter(track=['python', 'javascript', 'ruby'])
ich diese Fehlerinformationen zu erhalten:
requests.exceptions.ConnectionError: HTTPSConnectionPool(host='stream.twitter.com', port=443): Max retries
exceeded with url: /1.1/statuses/filter.json?delimited=length (Caused by NewConnectionError('<requests.packages.urllib3.connection.VerifiedHTTPSConnection object at 0x0000000002EABD30>:
Failed to establish a new connection: [Errno 10060] ',))
Ich bin ein Anfänger von Python in China, bitte helfen Sie mir, Ihnen danken!
Es scheint ein Netzwerkproblem zu sein –
Ich denke, dass es mit den Chinesen in Verbindung stehen kann nicht auf Twitter zugreifen. Und ich habe diesen Code hinzugefügt Proxy:
'Proxy = {'http': 'http: //127.0.0.1: 1080', 'https': 'https: //127.0.0.1: 1080'} proxy_support = urllib2.ProxyHandler (proxy) opener = urllib2.build_opener (proxy_support) urllib2.install_opener (Öffner) ' Aber es funktioniert nicht. – ShanGuangdi
Durch was treten Sie durch? –