-
Notifications
You must be signed in to change notification settings - Fork 139
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
newsapi.newsapi_exception.NewsAPIException #59
Comments
I've tried to replicate this in Python 2.7.17 and 3.7.4 with the following results. python3: I started with Python 3 because I am more familiar with it. The snippet you've supplied works as expected with a caveat; are you using a free plan? If so, you will get the following exception: Traceback (most recent call last):
File "/home/daniel/Code/junkyard/newsapi_test.py", line 12, in <module>
page=2)
File "/home/daniel/.virtualenvs/scripts/lib/python3.7/site-packages/newsapi/newsapi_client.py", line 261, in get_everything
raise NewsAPIException(r.json())
newsapi.newsapi_exception.NewsAPIException: {'status': 'error', 'code': 'parameterInvalid', 'message': 'You are trying to request results too far in the past. Your plan permits you to request articles as far back as 2019-09-26, but you have requested 2018-10-01. To extend this please upgrade to a paid plan.'} Adjusting the python2: Running the same Traceback (most recent call last):
File "/home/daniel/Code/junkyard/newsapi_test.py", line 12, in <module>
page=2)
File "/home/daniel/.virtualenvs/py2/lib/python2.7/site-packages/newsapi/newsapi_client.py", line 261, in get_everything
raise NewsAPIException(r.json())
newsapi.newsapi_exception.NewsAPIException Again, adjusting the For clarity, the snippet I used to get it working: all_articles = newsapi.get_everything(q='bitcoin',
sources='bbc-news,the-verge',
domains='bbc.co.uk,techcrunch.com',
from_param='2019-10-01',
to='2019-10-12',
language='en',
sort_by='relevancy',
page=2) Without doing much more investigation than that, I would suggest it is a case of the exception not raising as expected in Python 2 and leaving the user guessing as to the problem. Hope that helps, or gets us looking at it. |
While trying to run the following code snippet , which is actually a part of documentation :
I am getting this error again and again :
Any suggestions on why this might be happening ?
The text was updated successfully, but these errors were encountered: