小编use*_*175的帖子

Tweepy Streaming API为启用地理位置的推文上的坐标返回"无"

我正在使用Tweepy来访问流API.我可以使用下面的代码获得结果,但对于Geo Enabled值为"True"的推文,我得到的坐标返回值为"False".怎么会这样?我是否需要解码为status.coordinates返回的JSON对象?

from tweepy.streaming import StreamListener
from tweepy import OAuthHandler
from tweepy import Stream
import random
import time
import MySQLdb
import json

consumer_key="XXX"
consumer_secret="XXX"

access_token="XXX"
access_token_secret="XXX"

db=MySQLdb.connect(host='localhost', user='XXX', passwd='XXX', db='twitter')
db.set_character_set('utf8')

Coords = dict()
Place = dict()
PlaceCoords = dict()
XY = []
curr=db.cursor()

class StdOutListener(StreamListener):
    """ A listener handles tweets that are the received from the stream.
    This is a basic listener that inserts tweets into MySQLdb.
    """
    def on_status(self, status):

        print "Tweet Text: ",status.text

        text = status.text

        print …
Run Code Online (Sandbox Code Playgroud)

python twitter tweepy twitter-streaming-api

2
推荐指数
1
解决办法
7063
查看次数

标签 统计

python ×1

tweepy ×1

twitter ×1

twitter-streaming-api ×1