How to filter tweets (status) with tweepy (Cursor)

0

I took the following code from the book "Mastering social media mining with python", which saves all the tweets of a user in the JSON format. But I'd like it saved in json only tweets of a certain date. How to do?

This is the code that saves all tweets:

fname2=dirname
fname2+= "/user_timeline.jsonl"

with open(fname2, 'w') as f:
    for page in Cursor(client.user_timeline, screen_name=screen_name, count=200).pages(16):
        for status in page:
            f.write(json.dumps(status._json)+"\n")

This is the structure of JSON: link

How can I make this filter? Another detail is that in JSON comes a tweet after the other between {} but there is no key for it (without "Tweet": {.....})

Thank you!

    
asked by anonymous 11.09.2018 / 22:13

1 answer

0

This code converts the string to a date:

from dateutil.parser import parse

date = parse(date)
    
25.11.2018 / 21:13