[英]webbrowser table area td to How scraped information in 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();
}
}
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.