Using twython to log all screen_names of users who posted about a certain keyword on a certain date

38 Views Asked by At

I am trying to print all screen_names found on a search result with Twython.

Here is my current code

#Import the required modules
from twython import Twython

#Setting the OAuth
Consumer_Key = ''
Consumer_Secret = ''
Access_Token = '-'
Access_Token_Secret = ''

#Connection established with Twitter API v1.1
twitter = Twython(Consumer_Key, Consumer_Secret,
                  Access_Token, Access_Token_Secret)

#Twitter is queried
response = twitter.search(q='Roblox', since='2017-02-25', until='2017-02-26')

for tweet in response["statuses"]:
    st = tweet["entities"]["user_mentions"]
    screen_name = st[0]["screen_name"]
    f = open("output.txt", "a")
    f.write(str(screen_name, ",\n"))
    print(screen_name)
    f.close()

but it is not editing or printing in the log file. Right as I start it, the program stops with no apparent error.

(the codes have been filled in, just removed for the post)

0

There are 0 best solutions below