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获取模块路径