Typeerror: __init__() Got An Unexpected Keyword Argument 'wait_on_rate_limit'
Solution 1:
It worked fine for me after removing wait_on_rate_limit_notify=True
.
There is no such argument mentioned in docs:
class tweepy.API(auth=None, *, cache=None, host='api.twitter.com', parser=None, proxy=None, retry_count=0, retry_delay=0, retry_errors=None, timeout=60, upload_host='upload.twitter.com', user_agent=None, wait_on_rate_limit=False)
See docs.
Solution 2:
import tweepy
from tweepy import Stream
from tweepy import OAuthHandler
from tweepy.streaming import Stream
import pandas as pd
import json
import csv
import sys
import time
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)
if (not api):
print ("Can't Authenticate")
sys.exit(-1)
else:
print ("Scraping data now") # Enter lat and long and radius in Kms q='hello'
cursor = tweepy.Cursor(api.search_tweets, q="truffles", result_type="new", geocode="55.0000,4.0000,1000km",lang='en',count=100)
results=[]
for item in cursor.items(1000): # Remove the limit to 1000
results.append(item)
deftoDataFrame(tweets):
# COnvert to data frame
DataSet = pd.DataFrame()
DataSet['tweetID'] = [tweet.idfor tweet in tweets]
DataSet['tweetText'] = [tweet.text.encode('utf-8') for tweet in tweets]
DataSet['tweetRetweetCt'] = [tweet.retweet_count for tweet in tweets]
DataSet['tweetFavoriteCt'] = [tweet.favorite_count for tweet in tweets]
DataSet['tweetSource'] = [tweet.source for tweet in tweets]
DataSet['tweetCreated'] = [tweet.created_at for tweet in tweets]
DataSet['userID'] = [tweet.user.idfor tweet in tweets]
DataSet['userScreen'] = [tweet.user.screen_name for tweet in tweets]
DataSet['userName'] = [tweet.user.name for tweet in tweets]
DataSet['userCreateDt'] = [tweet.user.created_at for tweet in tweets]
DataSet['userDesc'] = [tweet.user.description for tweet in tweets]
DataSet['userFollowerCt'] = [tweet.user.followers_count for tweet in tweets]
DataSet['userFriendsCt'] = [tweet.user.friends_count for tweet in tweets]
DataSet['userLocation'] = [tweet.user.location for tweet in tweets]
DataSet['userTimezone'] = [tweet.user.time_zone for tweet in tweets]
DataSet['Coordinates'] = [tweet.coordinates for tweet in tweets]
DataSet['GeoEnabled'] = [tweet.user.geo_enabled for tweet in tweets]
DataSet['Language'] = [tweet.user.lang for tweet in tweets]
tweets_place= []
#users_retweeted = []for tweet in tweets:
if tweet.place:
tweets_place.append(tweet.place.full_name)
else:
tweets_place.append('null')
DataSet['TweetPlace'] = [i for i in tweets_place]
#DataSet['UserWhoRetweeted'] = [i for i in users_retweeted]return DataSet
DataSet = toDataFrame(results)
DataSet.to_csv('Belgium_27.csv',index=False)
You had specified a time period however that seems to no longer be available for tweepy.
result type Specifies what type of search results you would prefer to receive. The current default is "mixed." Valid values include:
mixed : include both popular and real time results in the response
recent : return only the most recent results in the response
popular: return only the most popular results in the response count |count| until Returns tweets created before the given date. Date should be formatted as YYYY-MM-DD.
Keep in mind that the search index has a 7-day limit. In other words, no tweets will be found for a date older than one week. since_id |since_id| There are limits to the number of Tweets which can be accessed through the API. If the limit of Tweets has occurred since the since_id, the since_id will be forced to the oldest ID available. max_id |max_id| include_entities|include_entities|
Post a Comment for "Typeerror: __init__() Got An Unexpected Keyword Argument 'wait_on_rate_limit'"