When running,
search_tweets.py --max-results 100 --results-per-call 100 --filter-rule “from:@njtransit” --filename-prefix njtransit --no-print-stream --debug

get the following error
INFO:searchtweets.utils:writing to file njtransit.json
INFO:searchtweets.result_stream:using bearer token for authentication
DEBUG:searchtweets.result_stream:sending request
DEBUG:urllib3.connectionpool:Starting new HTTPS connection (1): api.twitter.com:443
DEBUG:urllib3.connectionpool:https://api.twitter.com:443 “POST /1.1/tweets/search/fullarchive/dev.json HTTP/1.1” 422 183
WARNING:searchtweets.result_stream:retrying request; current status code: 422
DEBUG:searchtweets.result_stream:sending request
DEBUG:urllib3.connectionpool:https://api.twitter.com:443 “POST /1.1/tweets/search/fullarchive/dev.json HTTP/1.1” 422 181
WARNING:searchtweets.result_stream:retrying request; current status code: 422
DEBUG:searchtweets.result_stream:sending request
DEBUG:urllib3.connectionpool:https://api.twitter.com:443 “POST /1.1/tweets/search/fullarchive/dev.json HTTP/1.1” 422 183
WARNING:searchtweets.result_stream:retrying request; current status code: 422
^CTraceback (most recent call last):
File “/Applications/miniconda3/bin/search_tweets.py”, line 207, in
main()
File “/Applications/miniconda3/bin/search_tweets.py”, line 201, in main
for tweet in stream:
File “/Applications/miniconda3/lib/python3.7/site-packages/searchtweets/utils.py”, line 140, in write_result_stream
yield from write_ndjson(_filename, stream)
File “/Applications/miniconda3/lib/python3.7/site-packages/searchtweets/utils.py”, line 95, in write_ndjson
for item in data_iterable:
File “/Applications/miniconda3/lib/python3.7/site-packages/searchtweets/result_stream.py”, line 208, in stream
self.execute_request()
File “/Applications/miniconda3/lib/python3.7/site-packages/searchtweets/result_stream.py”, line 260, in execute_request
rule_payload=self.rule_payload)
File “/Applications/miniconda3/lib/python3.7/site-packages/searchtweets/result_stream.py”, line 95, in retried_func
time.sleep(tries ** 2)

Any suggestions on how to fix this?
Thank you!

Did you try without the @?

from: Matches any Tweet from a specific user. The value must be the user’s Twitter numeric Account ID or username (excluding the @ character)

Thank you! - that was it.

1 Like