1

From here, I am trying to get data from stock quote for every 10 mins interval.

I used WebClient for downloading the page content and for parsing I used regular expressions. It is working fine for other urls. For the Particular URL, my parsing code not working.

I think it is the problem with javascript, When I load the page in Browser, after loading the page content, It took some extra time to plot the data. May be this guy is using some client side script for this page. Can anyone help me Please..........

2
  • What information do you want from that page? Commented Feb 20, 2010 at 12:41
  • Hi Mark, In that page I need Open Interest value. Commented Feb 20, 2010 at 13:08

2 Answers 2

4

HTML Agility Pack will save you tons of headaches. Try it instead of using regexps to parse HTML.

For what it's worth, in the page you link to the quote data is indeed in Javascript code, check http://www.nseindia.com/js/getquotedata.js and http://www.nseindia.com/js/quote_data.js

Sign up to request clarification or add additional context in comments.

4 Comments

+1 Agreed, and of course the obligatory link: stackoverflow.com/questions/1732348/…
Hello Vinko, one more doubt, I have downloaded the content of the link to String as like @Asad Butt suggests, When I see the source of this String there is no values(Open Interest) in it. I think those are dynamically generates this report using JavaScript, Is this situation can handle by the HTML Agility Pack?
@Raghavendra: No, you have to understand how the data is stored in the Javascript file, download it and obtain the relevant part.
I have gone through the javascript file and I found there is a Iframe and I got the exact link. From the above page, in middle part it contains a seperate URL to load data and I found it. Once again Thank you very much.......
2

as per @Vinko Vrsalovic answer, Html Agility pack is your friend. Here is a sample

  WebClient client = new WebClient();
  string source = client.DownloadString(url);

  HtmlAgilityPack.HtmlDocument document = new HtmlAgilityPack.HtmlDocument();
  document.LoadHtml(source);

  HtmlNodeCollection nodes = document.DocumentNode.SelectNodes("//*[@href]");

   foreach (HtmlNode node in nodes)
   {
    if (node.Attributes.Contains("class"))
    {
     if (node.Attributes["class"].Value.Contains("StockData"))
     {// Here is our info }
    }
   }

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.