New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
JSONDecodeError #93
Comments
I have the same issue, will update if i can figure it out |
This change ensures that nothing is done if the response does not have status_code 200. Previously .json() method was called upon an empty response. Fixes #93
Thank you so much, this seems to fix the issue. I have not looked at the output thoroughly. The JSON error re-appears regularly but the script continues anyway. I am not yet sure if the extracted data is complete, although I will leave any additional remarks here. |
Hi @taspinar |
@hengruo Thanks for the tip. I'll implement it in the bugfix_jsondecodeerror branch and add it to the PR. |
If a request which is supposed to be non-html (JSON) returns an empty response or a html response, it serialization leads to an error. This error is catched with a try / except. This fixes issue #93
This issue should be fixed with the latest version (0.6.2). |
I just experienced thesame issue. I get the error: The query did generate the json file with some tweets but I don't know if it returned all the tweets. |
same issue here. |
Having the same issue. I found out that the requests for which this error occurs have a status code I am also using a different proxy provider to have more different proxies. I am using proxyscrape.com and iterating over about 300 different proxies (instead of just 20 (i think) like vanilla twitterscraper). |
Hi @twollnik , how do you sleep the requests? There's no option for it, it's just a single command (I can see the poolsize option). |
I added the following code to Anyway, here is the code that I inserted into # be nice to twitter
delays = [7, 4, 6, 2, 10, 19, 1]
delay = np.random.choice(delays)
sleep(delay) |
If a request which is supposed to be non-html (JSON) returns an empty response or a html response, it serialization leads to an error. This error is catched with a try / except. This fixes issue taspinar/twitterscraper#93
When running this:
twitterscraper "ethereum OR eth" -bd 2018-01-02 -ed 2018-01-15 -o bitcoin_tweets.json
I get this error:
ERROR:root:Failed to parse JSON "Expecting value: line 1 column 1 (char 0)" while requesting "https://twitter.com/i/search/timeline?f=tweets&vertical=default&include_available_features=1&include_entities=1&reset_error_state=false&src=typd&max_position=TWEET-949063965027569664-949067891449634816&q=ethereum%20OR%20eth%20since%3A2018-01-04%20until%3A2018-01-05&l=None".
Traceback (most recent call last):
File "c:\users....\appdata\local\programs\python\python36-32\lib\site-packages\twitterscraper\query.py", line 38, in query_single_page
json_resp = response.json()
File "c:\users....\appdata\local\programs\python\python36-32\lib\site-packages\requests\models.py", line 866, in json
return complexjson.loads(self.text, **kwargs)
File "c:\users....\appdata\local\programs\python\python36-32\lib\json_init_.py", line 354, in loads
return _default_decoder.decode(s)
File "c:\users....\appdata\local\programs\python\python36-32\lib\json\decoder.py", line 339, in decode
obj, end = self.raw_decode(s, idx=_w(s, 0).end())
File "c:\users....\appdata\local\programs\python\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)
Any idea why?
The text was updated successfully, but these errors were encountered: