Created
December 19, 2019 23:52
-
-
Save steveoni/e39c33d1c201f2cee26d885a38c76b8e to your computer and use it in GitHub Desktop.
crowd source data through mention
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import tweepy | |
import logging | |
from config import create_api | |
import time | |
logging.basicConfig(level=logging.INFO) | |
logger = logging.getLogger() | |
def Mention(api,since_id): | |
logger.info("Collecting info") | |
new_since_id = since_id | |
for tweet in tweepy.Cursor(api.mentions_timeline, | |
since_id=since_id).items(): | |
new_since_id = max(tweet.id, new_since_id) | |
if tweet.in_reply_to_status_id is not None: | |
status_id = tweet.in_reply_to_status_id | |
tweet_u = api.get_status(status_id,tweet_mode='extended') | |
print(tweet_u.full_text) | |
api.update_status( | |
status = "Nice one", | |
in_reply_to_status_id = tweet.id | |
) | |
return new_since_id | |
def main(): | |
api = create_api() | |
since_id = 1206662450784944136 #the last mention you have. | |
while True: | |
print(since_id) | |
since_id = Mention(api,since_id) | |
logger.info("Waiting...") | |
time.sleep(60) | |
if __name__ == "__main__": | |
main() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment