Tweepy Tweet提取

发布于 2025-01-23 12:18:36 字数 103 浏览 4 评论 0 原文

请共享一个完整的工作代码,以使用斜纹提取推文,您可以将消费者钥匙的位置空白。此外,我需要使用多个关键字和布尔操作员搜索推文,例如每个推文都提到瑞士和众多关键字之一。 瑞士和(学习,教育或就业)

Please share a full working code to extract tweets using Tweepy you can leave the place of consumer keys blank. Moreover, I need to search tweets using multiple keywords and boolean operators, like each tweet mentions Switzerland and one of the many keywords.
Switzerland AND (study OR education OR employment)

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

菩提树下叶撕阳。 2025-01-30 12:18:36

Stackoverflow不是要求人们代表您编码的地方。

“ https://docs.tweepy.org/en/stable/examples.html”中找到一个好的问题的起点。

import tweepy

bearer_token = ""

client = tweepy.Client(bearer_token)

# Search Recent Tweets

# This endpoint/method returns Tweets from the last seven days

response = client.search_recent_tweets("Tweepy")
# The method returns a Response object, a named tuple with data, includes,
# errors, and meta fields
print(response.meta)

# In this case, the data field of the Response returned is a list of Tweet
# objects
tweets = response.data

# Each Tweet object has default ID and text fields
for tweet in tweets:
    print(tweet.id)
    print(tweet.text)

# By default, this endpoint/method returns 10 results
# You can retrieve up to 100 Tweets by specifying max_results
response = client.search_recent_tweets("Tweepy", max_results=100)

您可以在瑞士(学习或教育或就业)

您将在 search_recent_tweets search_recent_tweets 的更多详细信息.org/en/stable/client.html#tweepy.client.search_recent_tweets“ rel =“ nofollow noreferrer”> Tweepy Documentation

最后,如果您需要帮助构建查询,则可以阅读 Twitter文档

Stackoverflow is not a place to ask people to code on your behalf.

You can find a good starting point for your question in the Tweepy examples:

import tweepy

bearer_token = ""

client = tweepy.Client(bearer_token)

# Search Recent Tweets

# This endpoint/method returns Tweets from the last seven days

response = client.search_recent_tweets("Tweepy")
# The method returns a Response object, a named tuple with data, includes,
# errors, and meta fields
print(response.meta)

# In this case, the data field of the Response returned is a list of Tweet
# objects
tweets = response.data

# Each Tweet object has default ID and text fields
for tweet in tweets:
    print(tweet.id)
    print(tweet.text)

# By default, this endpoint/method returns 10 results
# You can retrieve up to 100 Tweets by specifying max_results
response = client.search_recent_tweets("Tweepy", max_results=100)

You can adapt it with your query: Switzerland (study OR education OR employment)

You will find more details about the search_recent_tweets in the Tweepy documentation.

And finally, if you need help building the query, you can read the Twitter documentation.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文