Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/html/69.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
使用HTMLAgilitypack获取数据_Html_Vb.net_Html Agility Pack - Fatal编程技术网

使用HTMLAgilitypack获取数据

使用HTMLAgilitypack获取数据,html,vb.net,html-agility-pack,Html,Vb.net,Html Agility Pack,可以按照中的说明选择第一个文本。现在,要获得每对中文/日文英文文本,您可以迭代ul元素,然后从每个ul中获得包含目标文本的两个元素 以下是控制台应用程序演示: Dim node2 = HTMLDoc.DocumentNode.SelectNodes("//ul[@class='list-data-b-in']") If node2 IsNot Nothing Then For Each node In node2 Dim J

可以按照中的说明选择第一个文本。现在,要获得每对中文/日文英文文本,您可以迭代
ul
元素,然后从每个
ul
中获得包含目标文本的两个元素

以下是控制台应用程序演示:

Dim node2 = HTMLDoc.DocumentNode.SelectNodes("//ul[@class='list-data-b-in']")
        If node2 IsNot Nothing Then
            For Each node In node2
                Dim Japnodes As HtmlAgilityPack.HtmlNode = node.SelectSingleNode("//li[@class='text-jejp text-c']")
                txtMean.AppendText(Japnodes.InnerText)
                txtMean.AppendText(vbNewLine)
                Dim Engnodes As HtmlAgilityPack.HtmlNode = node.SelectSingleNode("//li[@class='text-jeen text-c']")
                txtMean.AppendText(Engnodes.InnerText)
                txtMean.AppendText(vbNewLine)
            Next

输出:

Dim lis = HTMLDoc.DocumentNode.SelectNodes("//li[@class='in-ttl-b']")
For Each li As HtmlNode in lis 
    Dim txt = li.SelectSingleNode("text()[1]")
    Console.WriteLine(txt.InnerText)
    For Each ul As HtmlNode in li.SelectNodes("ul")
        Dim japNode = ul.SelectSingleNode("li/span")
        Dim engNode = ul.SelectSingleNode("li[@class='text-jeen text-c']")

        Console.WriteLine(japNode.InnerText)
        Console.WriteLine(engNode.InnerText)
    Next
Next

可以按照中的说明选择第一个文本。现在,要获得每对中文/日文英文文本,您可以迭代
ul
元素,然后从每个
ul
中获得包含目标文本的两个元素

以下是控制台应用程序演示:

Dim node2 = HTMLDoc.DocumentNode.SelectNodes("//ul[@class='list-data-b-in']")
        If node2 IsNot Nothing Then
            For Each node In node2
                Dim Japnodes As HtmlAgilityPack.HtmlNode = node.SelectSingleNode("//li[@class='text-jejp text-c']")
                txtMean.AppendText(Japnodes.InnerText)
                txtMean.AppendText(vbNewLine)
                Dim Engnodes As HtmlAgilityPack.HtmlNode = node.SelectSingleNode("//li[@class='text-jeen text-c']")
                txtMean.AppendText(Engnodes.InnerText)
                txtMean.AppendText(vbNewLine)
            Next

输出:

Dim lis = HTMLDoc.DocumentNode.SelectNodes("//li[@class='in-ttl-b']")
For Each li As HtmlNode in lis 
    Dim txt = li.SelectSingleNode("text()[1]")
    Console.WriteLine(txt.InnerText)
    For Each ul As HtmlNode in li.SelectNodes("ul")
        Dim japNode = ul.SelectSingleNode("li/span")
        Dim engNode = ul.SelectSingleNode("li[@class='text-jeen text-c']")

        Console.WriteLine(japNode.InnerText)
        Console.WriteLine(engNode.InnerText)
    Next
Next