newsapi-python icon indicating copy to clipboard operation
newsapi-python copied to clipboard

'us' is working but 'kr', 'jp', 'cn' .. are not working

Open hwk06023 opened this issue 9 months ago • 2 comments

# US
head_lines = newsapi.get_top_headlines(category='entertainment', country='us')

for x in head_lines['articles']:
    print('title:', x['title'])
    print('description:', x['description'])    
    print('url:', x['url'])
    # print('urlToImage:', x['urlToImage'])
    print('content:', x['content'])
    print()

->

news_api


head_lines = newsapi.get_top_headlines(category='entertainment', country='kr') # or 'jp' or 'cn' ....

print(top_headlines)

for x in head_lines['articles']:
    print('title:', x['title'])
    print('description:', x['description'])    
    print('url:', x['url'])
    # print('urlToImage:', x['urlToImage'])
    print('content:', x['content'])
    print()

->

news_api_kr


Hi. In my case, 'us' is working but 'kr', 'jp', 'cn' .. are not working. Is it not supported originally, or does there seem to be a problem?

Thank you.

hwk06023 avatar May 10 '24 06:05 hwk06023

I've encountered the same problem. The modul supported all the country codes when I first implemented it. Seems like a new issue to me.

lukasfasnacht avatar Jun 08 '24 22:06 lukasfasnacht

Found the problem: the "get_top_headlines" function has "en" as default language. Just change it to "None" like the other params.

one-littlebear avatar Aug 14 '24 13:08 one-littlebear