Iceloof / GoogleNews

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

search phrase with quotation #109

Open fazialnjd opened 1 year ago

fazialnjd commented 1 year ago

Hi. I search in news.google.com "laminated glass" and "polyvinyl butyral" and see multiple pages results; but when I send this phrase to googlesearch module; I am not getting any results. why? and how I can to fix it? (I am need exact result of this phrase.) this is my code:

    from GoogleNews import GoogleNews

    phrase = '"laminated glass" and "polyvinyl butyral"'
    googlenews = GoogleNews()
    googlenews.get_news(phrase)
    googlenews.results(sort=True)

thanks

HurinHu commented 1 year ago

I try to search them separately and without quotes then works, but not working with them together with quotes. Probably some parsing error. Will check it later. You can search these without quotations inside keywords.

prjvvl commented 1 year ago

This happened because the URL generated in the end contained plus rather than space please refer to the links below to understand the issue.

Expected URL: https://www.google.com/search?q=%22laminated%20glass%22%20and%20%22polyvinyl%20butyral%22&lr=lang_en&biw=1920&bih=976&source=lnt&&tbs=lr:lang_1en,sbd:1&tbm=nws&start=0

Actual URL: https://www.google.com/search?q=%22laminated%2Bglass%22%2Band%2B%22polyvinyl%2Bbutyral%22&lr=lang_en&biw=1920&bih=976&source=lnt&&tbs=lr:lang_1en,sbd:1&tbm=nws&start=0

Please refer to #117 for the solution.