【发布时间】:2017-05-26 01:25:16
【问题描述】:
这是我目前的代码
foreach (var listBoxItem in listBox_google_urls.Items)
{
var document = new HtmlWeb().Load(listBoxItem.ToString());
var files = document.DocumentNode.Descendants("a").Select(a => a.GetAttributeValue("href", ".mp3")).Where(h => h.Contains(".mp3")).ToArray();
listbox_urls.Items.AddRange(files);
}
这就是 listBox_google_urls.Items
web_search.Navigate("https://www.google.com/search?q=" + val + "+(mp3|wav|ac3|ogg|flac|wma|m4a) -inurl:(jsp|pl|php|html|aspx|htm|cf|shtml) intitle:index.of -inurl:(listen77|mp3raid|mp3toss|mp3drug|index_of|wallywashis)");
var search_results = this.web_search.Document.Links.Cast<HtmlElement>().Select(a => a.GetAttribute("href")).Where(h => h.Contains("http://")).ToArray();
listBox_google_urls.Items.AddRange(search_results);
listBoxItem.ToString() 输出example
问题是这种方法有效,但只能抓取链接的标题 他们是我如何解决它的方法?已经谢谢了
【问题讨论】:
-
你能发布一个 listBoxItem.ToString() 输出的例子吗?会更容易帮助你
-
@MarkRedfern 我编辑你可以检查一下
-
您是要获取链接文本还是链接 URL?
-
这样的url链接我想提取网页上的所有url都是这样的78.140.251.40/tmp_audio/top100/rr/…@MarkRedfern
标签: c# html html-agility-pack