Python 3.x 基于特定标签提取数据/推文
我想根据特定的标签提取数据/推文。除了“#LetsTaxThis”,我的python代码可以与任何哈希标记一起正常工作。这主要是我想用来从推特中提取数据的标签 一旦我使用这个标签运行我的代码,我只能看到2条tweet,但是已经有1000多条使用这个标签的tweet 我的消费者密钥、消费者密钥、访问令牌和访问密钥都可以。因为其他hashtag正在工作Python 3.x 基于特定标签提取数据/推文,python-3.x,twitter,data-science,Python 3.x,Twitter,Data Science,我想根据特定的标签提取数据/推文。除了“#LetsTaxThis”,我的python代码可以与任何哈希标记一起正常工作。这主要是我想用来从推特中提取数据的标签 一旦我使用这个标签运行我的代码,我只能看到2条tweet,但是已经有1000多条使用这个标签的tweet 我的消费者密钥、消费者密钥、访问令牌和访问密钥都可以。因为其他hashtag正在工作 import tweepy # To consume Twitter's API import pandas as pd
import tweepy # To consume Twitter's API
import pandas as pd # To handle data
import numpy as np # For number computing
# For plotting and visualization:
from IPython.display import display
import matplotlib.pyplot as plt
import seaborn as sns
%matplotlib inline
# Twitter App access keys for @user
# Consume:
CONSUMER_KEY = '--------'
CONSUMER_SECRET = '----------------'
# Access:
ACCESS_TOKEN = '--------------'
ACCESS_SECRET = '-------------'
#------------------
# We import our access keys:
from credentials import * # This will allow us to use the keys as variables
# API's setup:
def twitter_setup():
"""
Utility function to setup the Twitter's API
with our access keys provided.
"""
# Authentication and access using keys:
auth = tweepy.OAuthHandler(CONSUMER_KEY, CONSUMER_SECRET)
auth.set_access_token(ACCESS_TOKEN, ACCESS_SECRET)
# Return API with authentication:
api = tweepy.API(auth)
return api
------------------
# We create an extractor object:
extractor = twitter_setup()
# We create a tweet list as follows:
#tweets = extractor.user_timeline(screen_name="@iamsrk", count=600)
tweets = extractor.search(q="#letsTaxThis", count=200)
print("Number of tweets extracted: {}.\n".format(len(tweets)))
# We print the most recent 5 tweets:
#print("3 recent tweets:\n")
for tweet in tweets[:3]:
print(tweet.text)
print()
-----------------------
我期待着您的来信:)
提前感谢:)搜索API只返回一周前的推文。您需要获得批准才能使用Premium Search API获取较旧的推文。为mate Jonas的回答干杯。我如何才能获得使用Premium Search API获取旧推文的批准。高级谢谢:)就行了,乔纳斯干杯