ranahaani / GNews

A Happy and lightweight Python Package that Provides an API to search for articles on Google News and returns a JSON response.
https://pypi.org/project/gnews/
MIT License
728 stars 107 forks source link

google_news.results and google_news.language not working #52

Closed csx-stack closed 1 year ago

csx-stack commented 1 year ago

Hi,

First of all, thank you so much for creating GNews.

Next, I have some issues with google_news.results and google_news.language. Can I kindly check if these 2 are working? I have tested them separately, but the responses are inconsistent and undesirable. For google_news.results, when setting "google_news.results = 10", I have gotten >10 responses for some keywords, e.g. searching 'Huawei', I get more than 10 responses.

As for google_news.language, when setting "google_news.language = 'chinese simplified'", I do not get news in simplified chinese. However, it works fine with Google search. E.g. searching for ”华为“ (Huawei in simplified chinese), I do not get any news in simplified chinese, but instead get news in English.

Look forward to your response. Thank you.

ranahaani commented 1 year ago

There was a typo mistake in README.md. you can limit number of responses using the max_results attribute.

google_news.max_results = 2

and to get Chinese news you also need to set the country too.

google_news.max_results = 2
google_news.language = 'chinese simplified'
google_news.country = 'China'
[{'title': '王毅:中俄战略合作没有止境,没有禁区,没有上限 - 新华网', 'description': '王毅:中俄战略合作没有止境,没有禁区,没有上限  新华网', 'published date': 'Sat, 02 Jan 2021 08:00:00 GMT', 'url': 'https://news.google.com/rss/articles/CBMiOmh0dHA6Ly93d3cueGluaHVhbmV0LmNvbS93b3JsZC8yMDIxLTAxLzAyL2NfMTEyNjkzNzkyNy5odG3SAQA?oc=5&hl=en-PK&gl=PK&ceid=PK:en', 'publisher': {'href': 'http://www.xinhuanet.com', 'title': '新华网'}}, {'title': '特朗普任期功过回顾:撼动美国政坛与国际形势的总统 - BBC', 'description': '特朗普任期功过回顾:撼动美国政坛与国际形势的总统  BBC', 'published date': 'Mon, 18 Jan 2021 08:00:00 GMT', 'url': 'https://news.google.com/rss/articles/CBMiMGh0dHBzOi8vd3d3LmJiYy5jb20vemhvbmd3ZW4vc2ltcC93b3JsZC01NTY3NDcxNNIBAA?oc=5&hl=en-PK&gl=PK&ceid=PK:en', 'publisher': {'href': 'https://www.bbc.com', 'title': 'BBC'}}]