在HTML文件中找到HTML链接 [英] Find the Html Link in html file

查看:94
本文介绍了在HTML文件中找到HTML链接的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要找到html文件中的多少链接,例如按钮,超链接等.

I need to find the how many link in html files like button,hyperlink etc

推荐答案

如果您愿意使用该工具,则HTMLAgilityPack是正确的工具,我会说.它是开源的,免费的并且用途广泛.

http://htmlagilitypack.codeplex.com/ [ ^ ]

一个简单的代码段
If you are open to use tool, HTMLAgilityPack is the right tool, I would say. It is open-source, free and pretty versatile.

http://htmlagilitypack.codeplex.com/[^]

A simple snippet
HtmlWeb hw = new HtmlWeb();
 HtmlDocument htmlDoc = hw.Load("www.yoursite.com/default.aspx);
 foreach(HtmlNode eachLink in htmlDoc.DocumentElement.SelectNodes("//a[@href]"))
 {

 }


如果您想编写自己的工具,建议您查看 http://www.dotnetperls.com/scraping-html [^ ]

不过,这只是开始,如果您尝试废弃其他网站,则可能会遇到很多问题,因为互联网上到处都是写得不好的网站:-(

希望能有所帮助.如果是这样,请标记答案/upvote.

谢谢
Milind


If you want to write your own tool, I would suggest to have a look at http://www.dotnetperls.com/scraping-html[^]

Though, this is just begining and you may face lots of issues if you are trying to scrap other sites as the internet is full of badly written sites :-(

Hope that helps. If it does, mark the answer /upvote.

Thanks
Milind


这篇关于在HTML文件中找到HTML链接的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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