您好, 欢迎来到 !    登录 | 注册 | | 设为首页 | 收藏本站

python-2.7 – 如何使用tweepy.Cursor和api.search从Tweepy中提取Hashtags?

5b51 2022/1/14 8:20:16 python 字数 2205 阅读 472 来源 www.jb51.cc/python

Tweepy通过应用tweepy.Cursor和api.search方法(如下所示)提取了我需要的所有其他信息(除了主题标签).我从文档中知道Hashtags属于这种结构状态>实体>井号标签.我试图找到(下面)方法中的“hashtags”目录,但无济于事: print "tweet", dir(tweet) print "////////////////" print "tweet._api",

概述

print "tweet",dir(tweet)
print "////////////////"
print "tweet._api",dir(tweet._api)
print "////////////////"
print "tweet.text",dir(tweet.text)
print "////////////////"
print "tweet.entities",dir(tweet.entities)
print "////////////////"
print "tweet.author",dir(tweet.author)
print "////////////////"
print "tweet.user",dir(tweet.user)

我的代码在这里

import tweepy

ckey = ""
csecret = ""
atoken = ""
asecret = ""

OAUTH_KEYS = {'consumer_key':ckey,'consumer_secret':csecret,'access_token_key':atoken,'access_token_secret':asecret}
auth = tweepy.OAuthHandler(OAUTH_KEYS['consumer_key'],OAUTH_KEYS['consumer_secret'])
api = tweepy.API(auth)

for tweet in tweepy.Cursor(api.search,q=('"good book"'),since='2014-09-16',until='2014-09-17').items(5):

    print "Name:",tweet.author.name.encode('utf8')
    print "Screen-name:",tweet.author.screen_name.encode('utf8')
    print "Tweet created:",tweet.created_at
    print "Tweet:",tweet.text.encode('utf8')
    print "Retweeted:",tweet.retweeted
    print "Favourited:",tweet.favorited
    print "Location:",tweet.user.location.encode('utf8')
    print "Time-zone:",tweet.user.time_zone
    print "Geo:",tweet.geo
    print "//////////////////"
print tweet.entities.get('hashtags')

总结

以上是编程之家为你收集整理的python-2.7 – 如何使用tweepy.Cursor和api.search从Tweepy中提取Hashtags?全部内容,希望文章能够帮你解决python-2.7 – 如何使用tweepy.Cursor和api.search从Tweepy中提取Hashtags?所遇到的程序开发问题。


如果您也喜欢它,动动您的小指点个赞吧

除非注明,文章均由 laddyq.com 整理发布,欢迎转载。

转载请注明:
链接:http://laddyq.com
来源:laddyq.com
著作权归作者所有。商业转载请联系作者获得授权,非商业转载请注明出处。


联系我
置顶