Last night when I asked about screen scrapping, I had an excellent article link and I found it at this point is. I have some questions but I will post my code as well as the following HTML source below. I am trying to get data between data tables, and then send data to a SQL table. I have got success in grabbing the Widgets Widget 3.5 Act ... which has been modified in the end but img src = / ...... in "1/2" TR = "00721408" not even get the number I have been stuck as a way to change code, so that all the data in the table can be captured .2, I have to do next to prepare the data to be sent in a SQL table. My code is as follows: / P> This way something delicate will work in your case - basically just text content All images including code> System.Collections.Generic Using the System.Linq; Using the System.text; Using the HtmlAgilityPack; Using System.Windows.Forms; Name Location ConsoleApplication1 {} Class Program {static void key (string [] args) { // go to WebGet = New HtmlWeb () on the HTML document; Go to doc = webGet.Load ("http: // local host"); // Documents HtmlNodeCollection table = doc.DocumentNode in all tables. "); // Repeat all rows in the first table HtmlNodeCollection Rows = Tables [0]. Select ( For ".// tr"); for (int i = 0; I & lt; Rows.account; ++ i) {// Repeat all columns in this line html LNodeCollection cols = rows [i]. Select (".// td"); For (int j = 0; j & lt; cols.Count; ++ j) {// get the value of the column and print it string value = colors [j] Inner text; Console.WriteLine (value); }}}} & Lt; Table class = "data" & gt; & Lt; TR & gt; & Lt; TD & gt; Part-digits & lt; / TD & gt; & Lt; TD width = "50" & gt; & Lt; / TD & gt; & Lt; TD & gt; & Lt; Img src = "/ partcode / number / 072,140" alt = "072,140" /> & Lt; / TD & gt; & Lt; / TR & gt; & Lt; TR & gt; & Lt; TD & gt; Manu number & lt; / TD & gt; & Lt; TD width = "50" & gt; & Lt; / TD & gt; & Lt; TD & gt; & Lt; Img src = "/ partcode / manu / 00,721,408" alt = "00721408" /> & Lt; / Td> & Lt; / Tr & gt; & Lt; TR & gt; & Lt; TD & gt; Details & lt; / TD & gt; & Lt; TD & gt; & Lt; / TD & gt; & Lt; TD & gt; Widgets 3.5 & lt; / TD & gt; & Lt; / TR & gt; & Lt; TR & gt; & Lt; TD & gt; Manu-country & lt; / TD & gt; & Lt; TD & gt; & Lt; / TD & gt; & Lt; TD & gt; United States & lt; / TD & gt; & Lt; / TR & gt; & Lt; Tr & gt; & Lt; Td> Last modified & lt; / Td> & Lt; Td> & Lt; / Td> & Lt; Td> 26 January 2011, 8:08 pm & lt; / Td> & Lt; / Tr & gt; & Lt; Tr & gt; & Lt; Td> Last modified by & lt; / Td> & Lt; TD & gt; & Lt; / Td> & Lt; Td> Manu & lt; / Td> & Lt; / Tr & gt; & Lt; / Table & gt; & Lt; P & gt; & Lt; / Body & gt; & Lt; / Html & gt;
alt attributes:
// Repeat all rows in the first table HtmlNodeCollection rows = tables [0]. Selection node (".// tr"); For (int i = 0; i & lt; rows.Count; ++ i) {// HtmlNodeCollection cols = rows [i] all columns in this row. Select (".// td"); For (int j = 0; j & lt; cols calculation; ++ j) {var images = cols [j]. Selection node ("img"); If (images = =) null (different image in images) (if image (image. ["Alt"]! = Null) console.light line (image properties ["alt"]. Value);} // column Get value and print it string value = colors [J] Inner text; Console.WriteLine (value);}}
Comments
Post a Comment