为什么这段 python 代码会出现 Synthax 错误?

问题描述 投票:0回答:0

我想解析 Twitter 上特定个人资料的“关注者”。这应该通过代码来完成,但我收到语法错误。有人可以帮我吗?非常感谢!

我收到的错误信息:

    api = tweepy.API(auth, wait_on_rate_limit=True, wait_on_rate_limit_notify=True)
TypeError: API.__init__() got an unexpected keyword argument 'wait_on_rate_limit_notify'
import tweepy

# credentials
consumer_key = "..."
consumer_secret = "..."
access_token = "..."
access_token_secret = "..."
bearer_token = "..."
import tweepy

# authenticate with Twitter API
auth = tweepy.OAuth1UserHandler(
    consumer_key, consumer_secret, access_token, access_token_secret
)
api = tweepy.API(auth, wait_on_rate_limit=True, wait_on_rate_limit_notify=True)

# set the username of the profile whose followings you want to extract
username = "example_username"

# get the user object of the profile
user = api.get_user(username)

# get the user's following count
following_count = user.friends_count

# create an empty list to store following profile URLs
following_urls = []

# loop through the followings and append their profile URLs to the list
for following in tweepy.Cursor(api.friends, id=username, count=200).items(following_count):
    following_urls.append(following.url)

# print the list of following profile URLs
print(following_urls)
python parsing twitter twitterapi-python
© www.soinside.com 2019 - 2024. All rights reserved.