如何在Asp.net中获取基于URL的网站元信息 [英] How to fetch website meta information based on URL in Asp.net
问题描述
专家,
我正在开发Simple Seo网站贸易业务
我正在使用c#,Asp.net.
我正在使用url获取元信息.
网站网址有一个文本框.使用该文本框我想显示元信息(标题,关键字,描述).
请帮我解决这个问题.
谢谢.感谢您的英语不好.
Hi Expert,
I am developing Simple Seo Website Trade biz
I am using c#,Asp.net.
And i am working on fetching meta information using url.
There is one textbox for website url.And using that i want to display meta information(title,keywords,description).
Please help me to solve this problem.
Thanks in adv.And sorry for poor english.
推荐答案
您可能需要使用一些第三方工具. HTMLAgilityPack是一种开放式源工具,可以用于此目的.
例如,要获取描述,您只需编写一小段代码
You probably need to use some third party tool. HTMLAgilityPack is one open soure tool which can be useful for the purpose.
For example to get description you can simply write a small code
HtmlDocument myDoc = new HtmlDocument();
myDoc.Load(path);
HtmlNode descNode = doc.DocumentNode.SelectSingleNode("//meta[@name='description']");
if (descNode != null)
{
string desc = descNode.GetAttributeValue("content", "");
}
该工具的链接: http://htmlagilitypack.codeplex.com/ [ http://htmlagilitypack.codeplex.com/wikipage?title=示例 [ ^ ]
希望能有所帮助.如果是这样,请将其标记为解决方案/upvote.
Milind
The link to the tool: http://htmlagilitypack.codeplex.com/[^]
Some examples at: http://htmlagilitypack.codeplex.com/wikipage?title=Examples[^]
Hope that helps. If it does, mark this as solution/upvote.
Milind
这篇关于如何在Asp.net中获取基于URL的网站元信息的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!