如何查找特定网站的RSS源?

Sha*_*han 52 rss

如何查找特定网站的RSS源?是否有任何特定的方法可以找到它?

Fra*_*nes 68

您可以通过查看主页(或博客)的来源找到它.寻找一条如下所示的行:

<link rel="alternate" type="application/rss+xml" title="RSS Feed" href="http://example.org/rss" />
Run Code Online (Sandbox Code Playgroud)

href值将是RSS所在的位置.

  • @ Cort3z你敢打赌!在某处可能有这样的东西:`<link rel ="alternate"type ="application/atom + xml"title ="ATOM Feed"href ="http://example.org/atom"/>`.关键是寻找`application/atom + xml`. (4认同)
  • 虽然title属性的值可能会改变. (3认同)

小智 14

有多种方法可以获取网站的RSS源.

您可以做的是获取网站的页面源并搜索此链接标记 type="application/rss+xml"

这将包含该网站的RSS源,如果有的话.

这是python中的一个简单程序,它将打印任何网站的RSS提要(如果有的话).

import requests  
from bs4 import BeautifulSoup  

def get_rss_feed(website_url):
    if website_url is None:
        print("URL should not be null")
    else:
        source_code = requests.get(website_url)
        plain_text = source_code.text
        soup = BeautifulSoup(plain_text)
        for link in soup.find_all("link", {"type" : "application/rss+xml"}):
            href = link.get('href')
            print("RSS feed for " + website_url + "is -->" + str(href))

get_rss_feed("http://www.extremetech.com/")
Run Code Online (Sandbox Code Playgroud)

使用.py扩展名保存此文件并运行它.它将为您提供该网站的RSS订阅源URL.

Google还提供API来查找网站的RSS源.请在此处找到它们:Google Feed API

  • Google的API现在已弃用。 (2认同)