How do you specify retrieving local news when using a Google News RSS URL?

核能气质少年 提交于 2019-12-06 03:25:02

问题


I am trying to build an RSS parser that users Google News RSS. I am able to retrieve news articles from the news URL just by targeting the following URL:

https://news.google.com/news/section?output=rss

However, on the google news page their is an option to retrieve news near your current location. This URL in the browser is:

https://news.google.com/news/section?geo=detect_metro_area

Just adding the output=rss query string parameter is not enough to return the local news in RSS format. Instead, I get a pretty much empty response:

<rss version="2.0">
<channel>
<generator>NFE/1.0</generator>
<title>News near you - Google News</title>
<link>
http://news.google.com/news?pz=1&ned=us&hl=en&geo=detect_metro_area
</link>
<language>en</language>
<webMaster>news-feedback@google.com</webMaster>
<copyright>&copy;2012 Google</copyright>
<pubDate>Tue, 20 Nov 2012 19:32:04 GMT</pubDate>
<lastBuildDate>Tue, 20 Nov 2012 19:32:04 GMT</lastBuildDate>
<image>
<title>News near you - Google News</title>
<url>
https://ssl.gstatic.com/news/img/logo/en_us/news.gif
</url>
<link>
http://news.google.com/news?pz=1&ned=us&hl=en&geo=detect_metro_area
</link>
</image>
<description>Google News</description>
</channel>
</rss>

Does anyone know if their is a way to get news that is near you geographically from this RSS feed?


回答1:


As far as I can tell you will need to determine that your self since the website is required to automatically determine your location using an on device mechanism or logged in user account. However if you would like to query based on news containing a city or area you could do something like this for New York. If you combine that for some on device geo location functions then you should be able to get news for what you would like.

https://news.google.com/news/section?output=rss&q=New%20York




回答2:


Replace ?geo=detect_metro_area with ?geo=Zip Code

Such as https://news.google.com/news/section?geo=90210

For RSS it would be https://news.google.com/news/feeds?geo=90210&output=rss



来源:https://stackoverflow.com/questions/13480710/how-do-you-specify-retrieving-local-news-when-using-a-google-news-rss-url

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!