Comments (4)
Hi @gabrieldespindula ,
I do not believe the language option is an available parameter for the top headlines endpoint. What is the current error you are receiving?
Thanks,
Matt
from newsapi-python.
Hey there, I tested and it does work in some different languages.
My point is just a small improvement.
Currently if you run:
from newsapi import NewsApiClient
newsapi = NewsApiClient(api_key='your key')
top_headlines = newsapi.get_top_headlines()
you get this exception:
Traceback (most recent call last):
File "", line 1, in
File "C:\Python27\lib\site-packages\newsapi\newsapi_client.py", line 119, in get_top_headlines
raise NewsAPIException(r.json())
newsapi.newsapi_exception.NewsAPIException
but if you send
top_headlines = newsapi.get_top_headlines(language='en')
It works just fine.
My suggestion is set 'en' as default language instead of 'None'. Look at newsapi_client.py line 12
Then would be possible to request the headlines without any argument. English language will be the default when sending the API.
And it also prevent new users from receiving this exception.
from newsapi-python.
Ok great. I think something may have changed, because this error is new. Either way, I think that is a great idea to default the language.
A PR would be fantastic, or I'll get around to updating it later this week.
Thanks!
from newsapi-python.
Corrected with pull request #25 .
from newsapi-python.
Related Issues (20)
- Best way to track search results by day HOT 2
- Trying to use qInTitle and getting error HOT 1
- Bug report HOT 1
- Issue with endpoint HOT 1
- Library Partial Import Error HOT 1
- Enable use of proxies
- Content is not fully returned when run get_top_headlines() HOT 1
- Add search_in parameters
- I already imported newsapi and i got sucessfully package installed but i am getting no module error for NewsApiClient HOT 4
- get_top_headlines() not working HOT 5
- Error regarding Newsapi-python get_top_headlines() HOT 3
- Language list contains unavaliable or invalid codes
- there are no data come back HOT 2
- is_valid_string is too restrictive
- Missing searchIn
- get full article text
- cant import newsapi HOT 1
- Can't get top headlines for some countries (even though supported by the API)
- ImportError: cannot import name 'NewsApiClient' from 'newsapi HOT 1
- 'us' is working but 'kr', 'jp', 'cn' .. are not working HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from newsapi-python.