我有以下代码可以提取 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);
}
}
}
但是我需要这个更具体。
谷歌的 Chrome 元素检查器有这个,我需要访问这个元素中的 URL:
<cite class="_Rm">www.dicksmith.com.au/apple-<b>ipad</b></cite>
该类是“_Rm”,它在一个“引用”标签中,我只需要那个 URL。