Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/regex/17.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
C# webbrowser表区td如何在textbox1中刮取信息?_C#_Regex_Winforms_Split_Htmlelements - Fatal编程技术网

C# webbrowser表区td如何在textbox1中刮取信息?

C# webbrowser表区td如何在textbox1中刮取信息?,c#,regex,winforms,split,htmlelements,C#,Regex,Winforms,Split,Htmlelements,我想从网站上刮取信息,在那里可以获得产品文件名和配置文件序列号 我如何刮产品序列号,如果总是来新的序列和下面的过程显示html代码 <pre> <td><b>product file number </b> 7269</td </pre> <pre> <td><b>product file number </b> 7562</td> </pre> <

我想从网站上刮取信息,在那里可以获得产品文件名和配置文件序列号

我如何刮产品序列号,如果总是来新的序列和下面的过程显示html代码

<pre> <td><b>product file number </b> 7269</td  </pre> 
<pre> <td><b>product file number </b> 7562</td> </pre> 
<pre> <td><b>product file number </b> 7502</td> </pre>

产品文件号7269您可以将数据视为XML

使用系统;
使用System.Collections.Generic;
使用System.Linq;
使用系统文本;
使用System.Xml;
使用System.Xml.Linq;
命名空间控制台应用程序45
{
班级计划
{
静态void Main(字符串[]参数)
{
字符串输入=
“产品文件号7269”+
“产品文件号7562”+
“产品档案号7502”;
//在数据周围添加根标记,以便只有一个根标记
input=string.Format(“{0}”,输入);
XElement root=XElement.Parse(输入);
var products=root.substands(“pre”)。选择(x=>new{
name=x.b.FirstOrDefault()值,
number=int.Parse(x.Element(“td”).Nodes().Skip(1).Take(1).FirstOrDefault().ToString())
}).ToList();
}
}
}
使用HTML解析器:)
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Xml;
using System.Xml.Linq;

namespace ConsoleApplication45
{
    class Program
    {
        static void Main(string[] args)
        {
            string input =
               "<pre> <td><b>product file number </b> 7269</td>  </pre>" +
               "<pre> <td><b>product file number </b> 7562</td> </pre>" +
               "<pre> <td><b>product file number </b> 7502</td> </pre>";

            //add root tag around data so you have only one root tag
            input = string.Format("<Root>{0}</Root>", input);

            XElement root = XElement.Parse(input);
            var products = root.Descendants("pre").Select(x => new {
                name = x.Descendants("b").FirstOrDefault().Value,
                number = int.Parse(x.Element("td").Nodes().Skip(1).Take(1).FirstOrDefault().ToString())
            }).ToList();


        }

    }

}