I read that HTMLAgility 1.4 is a great solution for cleaning a web page. As a new programmer, I hope that I can contribute to this project. I do this as a form of C # application. The page I'm working with is pretty straight forward. The information I need is stuck between the two tags and, My goal is to pull out the data for Part-Num, Manu-Number, Description, Manu-Country, Last Modified, Last Modified. From the page and send data to the sql table. One of them is that there is also a small png pic, which also needs to be captured from src = "/ partcode / number.
I have no code to be completed. I thought this piece of code would tell me I'm going in the right direction. Even entering into debugging, I do not see that he is doing anything. Maybe someone can point me in the right direction. The more detailed, the better, as it is obvious that I have something to learn. Thank you, I would really appreciate it.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using HtmlAgilityPack;
using System.Xml;
namespace Stats
{
class PartParser
{
static void Main(string[] args)
{
HtmlDocument doc = new HtmlDocument();
doc.LoadHtml("http://localhost");
var tables = doc.DocumentNode.SelectNodes("//table");
}
catch (Exception ex)
{
Console.WriteLine(ex.Message);
Console.WriteLine(ex.StackTrace);
Console.ReadKey();
}
}
}
}
Web Code:
<!DOCTYPE html
PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html;charset=UTF-8" />
<title>Part Number Database: Item Record</title>
<table class="data">
<tr><td>Part-Num</td><td width="50"></td><td><img src="/partcode/number/072140" alt="072140"/></td></tr>
<tr><td>Manu-Number</td><td width="50"></td><td><img src="/partcode/manu/00721408" alt="00721408" /></td></tr>
<tr><td>Description</td><td></td><td>Widget 3.5</td></tr>
<tr><td>Manu-Country</td><td></td><td>United States</td></tr>
<tr><td>Last Modified</td><td></td><td>26 Jan 2009, 8:08 PM</td></tr>
<tr><td>Last Modified By</td><td></td><td>Manu</td></tr>
</table>
<p>
</body>
</html>
source
share