python3获取模块路径_使用Python中的Getoldtweets3模块获取旧推文

python3获取模块路径

Library:

图书馆:

GetOldTweets3

GetOldTweets3 (GetOldTweets3)

GetOldTweets3 is a python module that will help to access the old tweets, as the Twitter API does not allow us to access the tweets of more than 1 week, but with the help of this module, we can access the tweets of any date and any topic and any username.

GetOldTweets3是一个python模块,将帮助访问旧的tweets,因为Twitter API不允许我们访问超过1周的tweets,但是借助此模块,我们可以访问任何日期和任何时间的tweets主题和任何用户名。

Code:

码:

# To create a base engine for the tweets:
GetOldTweets3.manager.TweetCriteria()

Code of the username:

用户名代码:

# importing the modules
import GetOldTweets3 as gt

# creating a base engine
engine=gt.manager.TweetCriteria()

# storing the tweets for the username
# setusername will set the username 
# of the account holder
Tweets=engine.setUsername("Donald Trump").setMaxTweets(3)

# extract the tweeets
# we will take the last third tweet
# gt.manager.TweetManager.getTweets 
# will extract the tweets
Tweets_Extracted=gt.manager.TweetManager.getTweets(Tweets)[2]

# print the tweet
print(Tweets_Extracted.text)

Output:

输出:

We will get the last third tweet of Donald Trump

You're the best! Sorry for the late reply here. 
This poor account is drowning in so much Trump bs, 
things meant for me get lost.

Code for the query searching:

查询搜索的代码:

# importing the modules
import GetOldTweets3 as gt

# creating a base engine
engine=gt.manager.TweetCriteria()

# storing the tweets for the 
# query or topic we want
# setthedate(year-month-day) to set 
# untill(year-month-day)
Tweet=engine.setQuerySearch("Corona Virus in india").setSince("2020-04-01").setUntil("2020-06-01").setMaxTweets(2)
# Extract The Tweets
Extracted_Tweets=gt.manager.TweetManager.getTweets(Tweet)[1]
# print the tweet
print(Extracted_Tweets.text)

Output:

输出:

Coronavirus live news: Brazil passes 500,000 Covid-19 cases 
as India extends lockdown in ‘high-risk’ zones | World news

Code for the username bounded with dates:

带有日期的用户名代码:

# importing the modules
import GetOldTweets3 as gt

# creating a base engine
engine=gt.manager.TweetCriteria()

# storing the tweets for the username 
# and setting the dates
# setthedate(year-month-day) to set 
# untill(year-month-day)
Tweet=engine.setUsername("narendramodi").setSince("2020-04-01").setUntil("2020-06-01").setMaxTweets(3)

# Extract The Tweets
# extract the third tweet
Extracted_Tweets=gt.manager.TweetManager.getTweets(Tweet)[2]

# print the tweeet
print(Extracted_Tweets.text)

Output:

输出:

अंतर्राष्ट्रीय योग दिवस जल्द ही आने वाला है। कोरोना संकट के दौरान लोग योग पर 
और अधिक गंभीरता से ध्यान दे रहे हैं। हर जगह लोगों ने योग के साथ-साथ 
आयुर्वेद को भी अपनाया है। सही मायने में योग 
Community, Immunity और Unity सबके लिए अच्छा है। #MannKiBaat


翻译自: https://www.includehelp.com/python/getting-old-tweets-using-getoldtweets3-module.aspx

python3获取模块路径

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值