【发布时间】:2016-06-26 16:27:30
【问题描述】:
我想用 htmlagility 包获取 Yahoo 结果页面的标题和 URL
HtmlWeb w = new HtmlWeb();
string SearchResults = "https://en-maktoob.search.yahoo.com/search?p=" + query.querytxt;
var hd = w.Load(SearchResults);
var nodes = hd.DocumentNode.SelectNodes("//a[@cite and @href]");
if (nodes != null)
{
foreach (var node in nodes)
{
{
string Text = node.Attributes["title"].Value;
string Href = node.Attributes["href"].Value;
}
}
它可以工作,但搜索结果中的所有链接都不是适当的链接如何省略广告链接、雅虎链接等。
我想访问正确的链接
【问题讨论】:
-
你看过 HTML 源代码吗?区分搜索结果链接和广告链接非常容易。
-
@Rick 他们在
<a class=" ac-algo ac-21th lh-15"你能指导我访问他们吗?
标签: c# html css asp.net html-agility-pack