使用CEF以正确的方式获取网站图标

编程入门 行业动态 更新时间:2024-10-15 00:24:58
本文介绍了使用CEF以正确的方式获取网站图标的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

嘿所有, 我只是想知道,有没有一个正确的方法来获取网站的favicon而不是从

http + Url.Host + / favicon.ico

?我知道网站通常设置这样的图标:

< meta content = / images / myfavicon.png itemprop = image > OR < link rel = icon type = image / x-icon href = / myfavicon.ico >

有没有办法搜索网站的HTML代码和使用CEF(用于VB.NET WinForms的ChromiumEmbedFramework)或webclient获取这些标签中的图标(我仍然不确定如何使用CEF从网站获取源代码)。 我真的很感激任何帮助! :D

解决方案

好的,我自己弄清楚了。我决定使用webclient并使用Google的Api来获取网站图标:

Dim Urlh As 新 Uri( www.google/s2/favicons?domain= + 新 Uri(Browser.Address)。主持人) Dim Img As Image = 新位图(新 IO.MemoryStream(新 WebClient() .DownloadData(Urlh))) Dim Img2 As 新位图(Img) Dim Img3 As 图标 Dim oIcon As Icon = Img 3.FromHandle(Img2.GetHicon) 我 .Icon = oIcon

希望这可以帮助其他人! ;)

Hey all, I was just wondering, is there a proper way to get a website's favicon without just getting it from

"http" + Url.Host + "/favicon.ico"

? I know that a website usually sets its favicon like this:

<meta content="/images/myfavicon.png" itemprop="image"> OR <link rel="icon" type="image/x-icon" href="/myfavicon.ico">

Is there a way I can search through the website's HTML code and get the icon from those tags using CEF (ChromiumEmbedFramework for VB.NET WinForms) or a webclient (I'm still not sure how to get the source code from a website using CEF). I would really appreciate any help! :D

解决方案

Ok, I managed to figure it out myself. I decided to use a webclient and use Google's Api to get the website favicon:

Dim Urlh As New Uri("www.google/s2/favicons?domain=" + New Uri(Browser.Address).Host) Dim Img As Image = New Bitmap(New IO.MemoryStream(New WebClient().DownloadData(Urlh))) Dim Img2 As New Bitmap(Img) Dim Img3 As Icon Dim oIcon As Icon = Img3.FromHandle(Img2.GetHicon) Me.Icon = oIcon

Hope this helps anyone else! ;)

更多推荐

使用CEF以正确的方式获取网站图标

本文发布于:2023-10-28 04:33:03,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1535532.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:图标   正确   方式   网站   CEF

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!