jsp - 如何使用 XSLT 或 JSP 检索网站的收藏夹图标?

标签 jsp web xslt favicon

我想在我的网站上列出特色网站,我认为尊重和使用他们的网站图标会很酷。如何从域中获取 JSP 或 XSLT 中任意 URL 的信息?我可以使用 PHP 或 javascript,但 XSLT 是首选方法。

最佳答案

要获取网站的图标,您需要加载每个特色网站的索引 HTML 并检查以下任一内容:

HTML:

<link rel="icon" type="image/vnd.microsoft.icon" href="http://example.com/image.ico">
<link rel="icon" type="image/png" href="http://example.com/image.png">
<link rel="icon" type="image/gif" href="http://example.com/image.gif">

XHTML:

<link rel="icon" type="image/vnd.microsoft.icon" href="/somepath/image.ico" />
<link rel="icon" type="image/png" href="/somepath/image.png" />
<link rel="icon" type="image/gif" href="/somepath/image.gif" />

Internet Explorer 可能使用稍微不同的格式:

<link rel="SHORTCUT ICON" href="http://www.example.com/myicon.ico" />

另请注意,由于大多数 Web 浏览器不需要 HTML 链接来检索收藏夹图标,因此您还应该检查 favicon.ico。在网站的文档根目录中,如果没有找到上述链接引用。

使用PHP,使用 file_get_contents($url) 很容易获取网页的HTML 内容。 :

$url = 'http://www.exmaple.com';
$output = file_get_contents($url);

关于jsp - 如何使用 XSLT 或 JSP 检索网站的收藏夹图标?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1990475/

相关文章:

java - 包含另一个列表的列表

html - div 背景和媒体查询不适用于 chrome,但适用于 firefox + edge + opera + smartphone

xslt - 在 XSLT 中使用函数

jsp - 支柱 1 : Accessing form values with bean:write

javascript - 将标题添加到 select2 下拉列表

用于登录 TopCoder 的 Perl 脚本

javascript - 在网页中嵌入条形码

xslt - 如何按原样复制所有内容并仅删除特定元素

xslt - 创建用于添加序列的递归字符串函数

eclipse - 在所有文件中插入空格而不是制表符