我想雅虎結果頁面的標題和URL與htmlagility包獲取雅虎結果頁面的標題和URL在c#
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
@他們在' mary