Asp.net HTML敏捷包语法
使用此代码片段,我获得了div中的所有详细信息……我只想要地址。不知道agility pack,但这里有一个直接的屏幕刮板:Asp.net HTML敏捷包语法,asp.net,html,vb.net,Asp.net,Html,Vb.net,使用此代码片段,我获得了div中的所有详细信息……我只想要地址。不知道agility pack,但这里有一个直接的屏幕刮板: Protected Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.Click Dim webGet = New HtmlWeb() Dim document = webGet.Load("http://www.ju
Protected Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim webGet = New HtmlWeb()
Dim document = webGet.Load("http://www.justdial.com/Guwahati/Bachelor-Cake/ct-10070075")
Dim nodes1 = document.DocumentNode.SelectNodes("//*[@class='logoDesc']")
For Each node In nodes1
MsgBox(node.InnerText)
Next node
End Sub
尝试以下操作(将“/text()”添加到XPath末尾):
可能重复:不,不是。实际上地址周围没有标记…所以我对如何获取地址感到困惑??我的意思是如何形成语法??尝试在之后选择节点并获取上一个#文本节点?@Tetsujinnoni我今天才开始使用HTML agility。你能给我指一些教程吗??或者给我举个例子??实际上没有星星……我只是用它们来突出显示地址……很抱歉搞混了:)
Protected Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim webGet = New HtmlWeb()
Dim document = webGet.Load("http://www.justdial.com/Guwahati/Bachelor-Cake/ct-10070075")
Dim nodes1 = document.DocumentNode.SelectNodes("//*[@class='logoDesc']")
For Each node In nodes1
MsgBox(node.InnerText)
Next node
End Sub
string page = Methods.GetPage("http://www.yoururl.com");
int firstStars = page.IndexOf("***");
string second = page.Substring(firstStars);
int secondStars = second.IndexOf("***");
//Add 3 to skip over the first three stars. May not need the +3, can't recall.
string address = page.Substring(0 + 3, secondStars);
public static string GetPage(string url)
{
WebClient webClient = new WebClient();
byte[] reqHTML;
string page = string.Empty;
UTF8Encoding objUTF8 = new UTF8Encoding();
try
{
reqHTML = webClient.DownloadData(url);
page = objUTF8.GetString(reqHTML);
}
catch (Exception theex)
{
}
return page;
}
Protected Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim webGet = New HtmlWeb()
Dim document = webGet.Load("http://www.justdial.com/Guwahati/Bachelor-Cake/ct-10070075")
Dim nodes1 = document.DocumentNode.SelectNodes("//*[@class='logoDesc']/text()")
For Each node In nodes1
MsgBox(node.InnerText)
Next node
End Sub