我想在我的网站上列出特色网站,我认为尊重和使用他们的网站图标会很酷。如何从域中获取 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/