Reputation: 53
There seem to be no key errors and valid credentials are in .twitter_keys.yaml file. error showing up at line result_stream_args-premium_search_args
twitter_search.py file
from searchtweets import ResultStream, gen_rule_payload, load_credentials, collect_results
import requests
premium_search_args = load_credentials("~/.twitter_keys.yaml",
yaml_key="search_tweets_premium",
env_overwrite=False)
rule = gen_rule_payload("superbowl", results_per_call=100) # testing with a sandbox account
print(rule)
from searchtweets import collect_results
tweets = collect_results(rule,
max_results=100,
result_stream_args=premium_search_args)
# print(tweets.all_text)
[print(tweet.all_text, end='\n\n') for tweet in tweets[0:10]];
Getting the following error:
C:\Users\hp\Dev\Twitter\twitter_search\src>python twitter_search.py
Grabbing bearer token from OAUTH {"query": "superbowl", "maxResults": 100} Traceback (most recent call last): File "twitter_search.py", line 17, in result_stream_args=premium_search_args) File "C:\Program Files (x86)\Python36-32\lib\site-packages\searchtweets\result_stream.py", line 308, in collect_results return list(rs.stream()) File "C:\Program Files (x86)\Python36-32\lib\site-packages\searchtweets\result_stream.py", line 208, in stream self.execute_request() File "C:\Program Files (x86)\Python36-32\lib\site-packages\searchtweets\result_stream.py", line 263, in execute_request resp = json.loads(resp.content.decode(resp.encoding)) File "C:\Program Files (x86)\Python36-32\lib\json__init__.py", line 354, in loads return _default_decoder.decode(s) File "C:\Program Files (x86)\Python36-32\lib\json\decoder.py", line 339, in decode obj, end = self.raw_decode(s, idx=_w(s, 0).end()) File "C:\Program Files (x86)\Python36-32\lib\json\decoder.py", line 357, in raw_decode raise JSONDecodeError("Expecting value", s, err.value) from None json.decoder.JSONDecodeError: Expecting value: line 1 column 1 (char 0)
Upvotes: 0
Views: 432
Reputation: 53
turned out to be the error was in the .twitter_keys.yaml file with the endpoint being incorrect. The endpoint in this case should have been
endpoint: https://api.twitter.com/1.1/tweets/search/30day/development.json
30day can be changed to full_archive etc.
Upvotes: 1