web浏览器表区域td到如何在textbox1中抓取信息



我想从网站收集信息,其中可用的产品文件名&配置文件序列号。

如果总是出现新序列号,我如何刮产品序列号&下面的过程显示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>

我是新的windows窗体应用程序区,所以请提供我完整的代码很好的帮助。如果你能帮助我,我真的很高兴。

您可以将数据视为XML

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();

        }
    }
}