Skip to content

Instantly share code, notes, and snippets.

@steveoni
Created December 19, 2019 23:52
Show Gist options
  • Save steveoni/e39c33d1c201f2cee26d885a38c76b8e to your computer and use it in GitHub Desktop.
Save steveoni/e39c33d1c201f2cee26d885a38c76b8e to your computer and use it in GitHub Desktop.
crowd source data through mention
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