Rajesh Kumar

Rajesh Kumar

  • 1.4k
  • 222
  • 36.5k

Scraping only <li> in C#

Jul 30 2014 9:53 AM

I am scraping a website, so far i was successful to get source code (I think its simple task). From the source code can we extract the contents inside <li> till </li>. Problem is there are two contents inside <li> first one is inside bold and second one doesn't have bold tag.

Similarly i have around 10-12 <li> Is there anyway we can create two columns and add these content in Datagridview one by one.

Here is my code so far :

string url = "http://geoportaal.maaamet.ee/url/xgis-ky.php?ky=41201:004:0067";
string strResult = "";
WebResponse objResponse;
WebRequest objRequest = System.Net.HttpWebRequest.Create(url);
objResponse = objRequest.GetResponse();
using (StreamReader sr = new StreamReader(objResponse.GetResponseStream()))
{
strResult = sr.ReadToEnd();
// Close and clean up the StreamReader
sr.Close();
}
MessageBox.Show(strResult);

Answers (10)