我知道如何制作一个机器人来转发包含特定标签或关键字的tweet: tag = 'My_keyword'
# Looping through tweets
for tweet in tweepy.Cursor(api.search, q=tag,
).items():
try:
print('\nTweet by: @' + tweet.user.screen_name)
# Retweet tweets as they are found
tweet.retweet()
print(
我正在尝试获取python中包含一个主题标签(比如"#kitten")的tweet的数量。
我在用tweepy。
然而,我发现的所有代码都是这样的:
query = "kitten"
for i, status in enumerate(tweepy.Cursor(api.search, q=query).items(50)):
print(i, status)
我有一个错误:'API‘对象没有属性'search’
Tweepy似乎不再喜欢这个东西了。有办法回答我的问题吗?
对不起我的英语不好。
我正在使用Tweepy.StreamingClient获得一些推特,但我无法获得用户名,即使我添加过滤器。我正在使用Tweepy的4.10.1版本
from tweepy import StreamingClient
class TweetStreamerV2(StreamingClient):
def on_tweet(self, tweet):
# here I tried the following and nothing is returned
print(tweet.inlcudes)
print(tweet.user)
stream
我正在尝试使用TweepyV4从所有的tweet中获取哈希标签。为了获取每条推文的哈希标签,我需要添加所需的扩展,并按照文档查看tweet_field‘实体’。
for response in tweepy.Paginator(client.get_users_tweets, user_id,
exclude='replies,retweets',
max_results=100,
我试着过滤掉包含特定主题标签的tweet,这很好,我甚至可以显示文本。但是,另外,我想打印user_screenname或作者的名字。但我的班级似乎只能显示tweet的文本,其他值都是0或0。
class MyStream(tweepy.StreamingClient):
# This function gets called when the stream is working
def on_connect(self):
print("Connected")
# This function gets called when a tweet passes th
我编写了一个简单的脚本来获得最流行的300个包含特定标签的tweet。
for self._tweet in tweepy.Cursor(self._api.search,q=self._screen_name,count=300, lang="en").items(300):
self._csvWriter.writerow([self._tweet.created_at, self._tweet.text.encode('utf-8')])
它运行良好,并将结果保存到CSV,但的tweet是截断的。
我像这样修改了代码,添加了twitter_
在tweepy中,我试图流式传输数据,但我只能在屏幕上显示少量的文本。我花了30分钟试图找到一个答案,但没有一个有效。我只是想获取完整的推文文本,谢谢 import tweepy
import json
from time import sleep
import requests
# Specify the account credentials in the following variables:
consumer_key = 'xxxxxxxxxx'
consumer_secret = 'xxxxxxxxxx'
access_token = '