Iceloof / GoogleNews

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

Can't get the actual link of an article using the googlenews.get_news() function #100

Closed LLukas22 closed 1 year ago

LLukas22 commented 1 year ago

The links returned from this methode always are 'https://news.google.com/articles' links which redirect to the actual newspage.

e.g.

from GoogleNews import GoogleNews
googlenews = GoogleNews(lang='en')
googlenews.get_news('APPLE')
result = googlenews.result()
link = result[0]['link']
print(link)

prints out 'https://news.google.com/articles/CAIiEELGVRtjjXjJ61KONg-uCHEqGQgEKhAIACoHCAowyNj6CjDyiPICMLXJpwc?uo=CAUidGh0dHBzOi8vd3d3LmNic25ld3MuY29tL2Vzc2VudGlhbHMvYWlycG9kcy1hcHBsZS13YXRjaGVzLWlwYWRzLWFuZC1tb3JlLXRoZS1iZXN0LWJhY2stdG8tc2Nob29sLWRlYWxzLW9uLWFwcGxlLXRlY2gv0gEA&hl=en-US&gl=US&ceid=US%3Aen' which redirects to the actual article 'https://www.cbsnews.com/essentials/airpods-apple-watches-ipads-and-more-the-best-back-to-school-deals-on-apple-tech/'

Is there some way to retrieve the actual url with this library?

HurinHu commented 1 year ago

That is the google link showing on the website, actually when you search news on google, it is not showing actual link for news, it shows this redirect link instead. Of course you can manually retrieve the actual link based on the redirect link, but you may need to do it one by one. It's not a good approach to make it available into the library.

alexanderfrey commented 1 year ago

Why is it not good ? If I remember correctly this link used to be the real link to the website and not some redirect. Could it be that google changed something ?

HurinHu commented 1 year ago

Why is it not good ? If I remember correctly this link used to be the real link to the website and not some redirect. Could it be that google changed something ?

No, if you check the link in the google news search results, all the link is redirected with google link, and that is the original link we can fetch from the webpage.