Iceloof / GoogleNews

Script for GoogleNews
https://pypi.org/project/GoogleNews/
MIT License
314 stars 88 forks source link

Searching a query with Google's search techniques #66

Open emremrah opened 3 years ago

emremrah commented 3 years ago

Thanks for the great work. I would like to be able to use Google's search techniques as described here.

I tried to achieve this as follows:

googlenews = GoogleNews(lang='en', encode='utf-8')
# googlenews.search('coronavirus')  # with this, I saw some articles about Scotland. So I changed it to ->
googlenews.search('coronavirus -scotland')
news = googlenews.results()

But the news are still related to Scotland.

Is it possible to have this feature? It would be very good to have Google's search operators.

HurinHu commented 3 years ago

It seems google doesn't have exclude feature for the news at the moment, we might not able to create this feature at current stage.

emremrah commented 3 years ago

Oh this is sad :( Okay then. This issue can be stay open as "feature request" if you would like to. It's a good feature IMO. Thanks for the work.

meesterguyman commented 1 year ago

I am attempting to do the following search: googlenews.get_news('"big bank" -lender -national')

I didn't get any results, so I decided to look into this. As it turns out, Google doesn't like the url this produces, which includes pluses in between terms. This is a result of line #256: key = "+".join(key.split(" "))

If you delete this line altogether, the pluses are gone, the url resolves correctly, and you get results. Since changing this single line will enable this additional functionality, might want to consider altering it.