I am using the (deprecated, but still functional) GoogleNews API to search for news pertaining to certain stocks that I follow. The API returns the source and a GoogleNews link to the article, but I would prefer the direct link from the source. Is there a method to use the GoogleNews link and retrieve the link to the direct article?
For reference, the GoogleNews API might return: http://news.google.com/./articles/CAIiEB8taITanutbSbv39RsNMyMqGQgEKhAIACoHCAow4uzwCjCF3bsCMIrOrwM?uo=CAUieWh0dHBzOi8vd3d3LmJsb29tYmVyZy5jb20vbmV3cy9hcnRpY2xlcy8yMDIyLTAxLTEwL2NoaW5hLXMtY29uc3VtZXJzLXJpc2stZm9tby1hcy1lbGVjdHJpYy1jYXJzLXBvcHVsYXJpdHktc29hcnMta3k4bHNjczbSAQA&hl=en-US&gl=US&ceid=US%3Aen
but I would prefer: https://www.bloomberg.com/news/articles/2022-01-10/china-s-consumers-risk-fomo-as-electric-cars-popularity-soars-ky8lscs6
Any help would be greatly appreciated!
Thank you in advance!
Try with requests
package:
import requests
url = 'http://news.google.com/...'
# Set cookie consentement and DON'T USER User-Agent
cookies = {'CONSENT': 'YES+cb.20210720-07-p0.en+FX+410'}
response = requests.head(url, cookies=cookies, allow_redirects=True)
print(response.history[-1].url)
# Output
https://www.bloomberg.com/news/articles/2022-01-10/china-s-consumers-risk-fomo-as-electric-cars-popularity-soars-ky8lscs6