Python beginner here, I'm modifying a piece of existing code (TwitterSearch on Github) to search Twitter for specific tweets that contain certain keywords using standard search API. I keep getting a Syntax Error, but it points me to blank space at the end of a line.
The thing is, the code worked once yesterday (as in I got the output I wanted) and then I tried to use it again and it keeps giving me SyntaxError.
At one point the error was at the end of the code - I deleted the last few lines and the error would simply move to whatever the end of the code was (but it always pointed at blank space rather than anything I had typed). Now it's moved to the blank space after the closing brackets following 'created at' (see below) I've been consistently indenting the same way throughout, so I don't think it's an indentation error. For reference, I'm using Jupyter Notebook.
These are the last four lines of the code:
for tweet in ts.search_tweets_iterable(tso):
print:('@%s tweeted: %s' % (tweet['user']['screen_name'], tweet['text']), (tweet['created_at'])) ^ **this is where the Syntax Error points to**
except TwitterSearchException as e
print:('e')
Any help would be much appreciated.
Have you tried removing :
from your print:(...
statement?
try:
tso = TwitterSearchOrder()
tso.set_keywords(['xx'])
tso.set_language('en')
tso.set_geocode('37.0902000', '-095.7129000', '1mi')
ts = TwitterSearch(
consumer_key = 'xxxx',
consumer_secret = 'xxxx',
access_token = 'xxxx',
access_token_secret = 'xxxx'
)
for tweet in ts.search_tweets_iterable(tso):
print('@%s tweeted: %s' % (tweet['user']['screen_name'], tweet['text']), (tweet['created_at']))
except TwitterSearchException as e:
print(e)