如何使用 tweepy 搜索 GIFS?
How to search GIFS using tweepy?
我正在使用 tweepy 搜索包含 GIFS.Twitter 的热门推文,提供了一些标准运算符来过滤 tweets.Click here 以查看它。
他们有一个运算符来查找包含 "puppy" 和 vine 的推文,因此他们应该有一个用于 GIFS。你能帮我搜索包含 GIFS 的热门推文吗?
我尝试了 "filter:animated_gif" 和 "filter:gif"
api = tweepy.API(auth)
results = api.search(q=" filter:gif", lang="en")
for tweet in results:
#rpp is recent public tweet
print(f"{tweet.user.name}:{tweet.text}")
似乎 filter:images
应该有效,如:
api = tweepy.API(auth) results = api.search(q=" filter:images", lang="en")
这将恢复所有图像,但您仍然可以通过查看 extended_entities/media/type
来判断其中哪些是 gif,如下所示:
{
...
"extended_entities": {
"media": [
{
"id": 1182059952640122881,
"id_str": "1182059952640122881",
"indices": [
207,
230
],
"media_url": "http://pbs.twimg.com/tweet_video_thumb/EGeFQ5xUYAE-94I.jpg",
"media_url_https": "https://pbs.twimg.com/tweet_video_thumb/EGeFQ5xUYAE-94I.jpg",
"url": "...",
"display_url": "pic.twitter.com/2wZccP1uMn",
"expanded_url": "https://twitter.com/NASAInSight/status/1182059967408271361/photo/1",
"type": "animated_gif",
"sizes": {
"thumb": {
"w": 150,
"h": 150,
"resize": "crop"
},
"large": {
"w": 1008,
"h": 956,
"resize": "fit"
},
"small": {
"w": 680,
"h": 645,
"resize": "fit"
},
"medium": {
"w": 1008,
"h": 956,
"resize": "fit"
}
},
"video_info": {
"aspect_ratio": [
252,
239
],
"variants": [
{
"bitrate": 0,
"content_type": "video/mp4",
"url": "https://video.twimg.com/tweet_video/EGeFQ5xUYAE-94I.mp4"
}
]
},
"ext_alt_text": null
}
]
},
...
}
注意 type
是 "animated_gif"。
我正在使用 tweepy 搜索包含 GIFS.Twitter 的热门推文,提供了一些标准运算符来过滤 tweets.Click here 以查看它。
他们有一个运算符来查找包含 "puppy" 和 vine 的推文,因此他们应该有一个用于 GIFS。你能帮我搜索包含 GIFS 的热门推文吗?
我尝试了 "filter:animated_gif" 和 "filter:gif"
api = tweepy.API(auth)
results = api.search(q=" filter:gif", lang="en")
for tweet in results:
#rpp is recent public tweet
print(f"{tweet.user.name}:{tweet.text}")
似乎 filter:images
应该有效,如:
api = tweepy.API(auth) results = api.search(q=" filter:images", lang="en")
这将恢复所有图像,但您仍然可以通过查看 extended_entities/media/type
来判断其中哪些是 gif,如下所示:
{
...
"extended_entities": {
"media": [
{
"id": 1182059952640122881,
"id_str": "1182059952640122881",
"indices": [
207,
230
],
"media_url": "http://pbs.twimg.com/tweet_video_thumb/EGeFQ5xUYAE-94I.jpg",
"media_url_https": "https://pbs.twimg.com/tweet_video_thumb/EGeFQ5xUYAE-94I.jpg",
"url": "...",
"display_url": "pic.twitter.com/2wZccP1uMn",
"expanded_url": "https://twitter.com/NASAInSight/status/1182059967408271361/photo/1",
"type": "animated_gif",
"sizes": {
"thumb": {
"w": 150,
"h": 150,
"resize": "crop"
},
"large": {
"w": 1008,
"h": 956,
"resize": "fit"
},
"small": {
"w": 680,
"h": 645,
"resize": "fit"
},
"medium": {
"w": 1008,
"h": 956,
"resize": "fit"
}
},
"video_info": {
"aspect_ratio": [
252,
239
],
"variants": [
{
"bitrate": 0,
"content_type": "video/mp4",
"url": "https://video.twimg.com/tweet_video/EGeFQ5xUYAE-94I.mp4"
}
]
},
"ext_alt_text": null
}
]
},
...
}
注意 type
是 "animated_gif"。