如何使用 Selenium 获取网站的 favicon [英] How can I get site's favicon using Selenium

查看:38
本文介绍了如何使用 Selenium 获取网站的 favicon的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要获取网站的图标.

I need to get web site's favicon.

我该怎么做?

推荐答案

您将无法使用 Selenium 获取网站图标,您必须使用另一个程序来获取它.您能够获得它的唯一方法是,如果您的网站将 favicon.ico 呈现为诸如

You won't be able to get the favicon with Selenium you would have to use another program to grab it. The only way you would be able to get it is if your website rendered the favicon.ico as a link such as

<link rel="shortcut icon"
 href="http://example.com/myicon.ico" />

然而,网站通常只是将 favicon.ico 存储在根目录中,并且在页面请求时浏览器会检索它并将其放置在地址栏或选项卡或使用 favicon 的任何地方.如果这是您的网站图标的呈现方式,那么将没有代码或任何可使用 Selenium 搜索的内容.

However typically websites just store the favicon.ico in the root directory and on page request the browser retrieves it and drops it in the address bar or tab or wherever favicons are used. If this is how your favicon is rendered then there will be no code or anything to search for with Selenium.

上述代码在运行时也对 IE7 有一些错误支持.

Also the above code while it does work has some buggy support for IE7.

这篇关于如何使用 Selenium 获取网站的 favicon的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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