ex的输入链接是" http://www.unionstationdc.com"。我需要以编程方式访问此处" http://www.unionstationdc.com/contact" &安培;获取此页面的内容。我在下面写了这段代码,但没有用。
doc = hw.Load(link);
foreach (HtmlNode link in doc.DocumentNode.SelectNodes("//a[@href]"))
{
bool hreflink = link.GetAttributeValue("p", true);
if (hreflink == true)
{
attr = link.Attributes;
att = attr.AttributesWithName("p");
for (int i = 0; i < attr.Count; i++)
{
name = attr[i].Name;
value = attr[i].Value;
string trim = value.Trim('/');
string uppercase = trim.ToUpper();
if (uppercase.Contains("CONTACT"))
{
string path = attr[i].XPath;
MessageBox.Show(path);
}
}
}
}
请帮我完成....提前致谢