c# - Parsing specific data from a webpage -


i getting data this webpage using following code block. think code block not reasonable because used bordercolor of table. not find different way data. there different way because newbie in c#.

thanks help.

foreach (htmlnode node in document.documentnode.selectnodes("//table[@bordercolor='#3366cc']/tr")) {     sxpath = node.xpath + "/td[2]/font[1]";     htmlnode = document.documentnode.selectsinglenode(sxpath);      if(htmlnode != null)     {         if (htmlnode.innertext.length >= 7)         {             string freq = htmlnode.innertext.substring(0, 5);             if (int.tryparse(freq, out intfrequency) == true)             {                 string pol = htmlnode.innertext.substring(6, 1);                 if (pol == "h")                     bpolarity = false;                 else if (pol == "v")                     bpolarity = true;             }         }     }      sxpath = node.xpath + "/td[3]/font[1]";     htmlnode = document.documentnode.selectsinglenode(sxpath);      if (htmlnode != null)     {         if (htmlnode.innertext.length >= 5)         {             string sr = htmlnode.innertext.substring(0, 5);             if (int.tryparse(sr, out intsymbolrate) == false)             {                 sr = htmlnode.innertext.substring(0, 4);                 int.tryparse(sr, out intsymbolrate);             }         }     } } 

try using web client() or http request getting content website simpler

sample code:

string winphonegeektweetsurl = @"http://sss.sss78.sset/wsss.php"; webclient webclient = new webclient(); webclient.downloadstringcompleted += new downloadstringcompletedeventhandler(webclient_downloadstringcompleted); webclient.downloadstringasync(new uri(winphonegeektweetsurl)); 

carry remaining function downloadstringcompleted event handler


Comments

Popular posts from this blog

javascript - Count length of each class -

What design pattern is this code in Javascript? -

hadoop - Restrict secondarynamenode to be installed and run on any other node in the cluster -