Twitter数据提取,多次提取相同的推文

时间:2019-09-29 11:38:25

标签: python python-3.x web-scraping twitterapi-python

我试图通过Tweet API从Twitter提取tweet。提取这些推文后,同一条推文会出现多次。

我正在使用以下代码提取推文:

from tweepy import OAuthHandler #For Authantication
from tweepy import API
from tweepy import Cursor
import pandas as pd
from datetime import date

# Authanticating the user

auth =  OAuthHandler(CONSUMER_KEY, CONSUMER_SECRET)
auth.set_access_token(ACCESS_TOKEN, ACCESS_TOKEN_SECRET)

api = API(auth, wait_on_rate_limit=True)
data = []


try:
    for tweet in Cursor(api.search, q='#realmeBudsWireless', lang = 'en').items(500):
        data.append(tweet.text)

except BaseException as e:
    print("Error on_data %s" % str(e))

df = pd.DataFrame(columns= ['Tweets'])
df['Tweets'] = data

以下是具有重复推文的数据框中提取的数据: Extracted Tweets with duplicate data

0 个答案:

没有答案