如何检查网站是否有 RSS 提要 [英] How to check if a site has rss feeds

查看:43
本文介绍了如何检查网站是否有 RSS 提要的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

假设我想制作一个以网站域名作为输入的网页,并检查该网站是否有 rss 提要.如果该站点有 RSS 提要,它会进入下一页.或者换句话说,只需检查给定的域名是否具有此标签-

Suppose I want to make a webpage that takes domain name of a website as input and checks if that site has rss feeds or not. And if that site has rss feeds, it proceeds to the next page. Or in other words, just check if that given domain name has this tag or not-

<link rel="alternate" type="application/rss+xml" 
      title="Something" 
      href="http://www.example.com/feed1.xml" />

我如何使用 php 或 javascript 执行此操作?

How do I do it using php or javascript ?

推荐答案

由于 同源政策,您将无法在 JavaScript 中实现它,您将需要 PHP.

Due to the same-origin policy, you won't be able to implement that in JavaScript, you'll need PHP.

下载解析页面,搜索xpathhtml>;head>link[@rel='alternate'].

Download and parse the page, and search for the xpath html>head>link[@rel='alternate'].

这篇关于如何检查网站是否有 RSS 提要的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆