简体   繁体   English

Python tweepy:仅在机器人启动后才发推文

[英]Python tweepy: Tweets only after bot starts

I want to write bot that searches for tweets after the bot starts.我想编写一个在机器人启动后搜索推文的机器人。 If the tweet has been tweeted before the bot starts working, the bot should ignore it.如果推文在机器人开始工作之前已经被发送,机器人应该忽略它。 I have this code right now:我现在有这个代码:

I am using Python and tweepy .我正在使用Pythontweepy

for tweet in tweepy.Cursor(api.mentions_timeline,
        since_id=since_id).items():
        new_since_id = max(tweet.id, new_since_id)

I don't know how to implement it, I thought about use time function and compare it with the time right now, but I don't know hot to get the time of the tweet.不知道怎么实现,想过用time函数和现在的时间对比一下,但是不知道hot获取tweet的时间。

Twitter's API doesn't allow for searching for tweets by time. Twitter 的 API 不允许按时间搜索推文。 You would have to compare the tweet's created_at attribute to the time at which your bot started.您必须created_at文的created_at属性与您的机器人启动的时间进行比较。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM