【发布时间】:2015-08-02 10:08:56
【问题描述】:
我有以下代码可以提取 Google 搜索结果中的所有 URL:
private void button1_Click(object sender, EventArgs e)
{
HtmlElementCollection a = webBrowser1.Document.GetElementsByTagName("a");
foreach (HtmlElement b in a)
{
string item = b.GetAttribute("href");
if (item.Contains("url?q="))
{
listBox1.Items.Add(item);
}
}
}
但是我需要更具体一点。
Google 的 Chrome 元素检查器有这个,我需要访问这个元素中的 URL:
<cite class="_Rm">www.dicksmith.com.au/apple-<b>ipad</b></cite>
类是“_Rm”,它在一个“引用”标签中,我只需要那个 URL。
【问题讨论】:
标签: c# webbrowser-control getelementsbytagname getattribute