Click here to Skip to main content
15,884,032 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi,

I am trying to fetch the HTML of one website through my console application and this is working fine till now.

Now there is one section in page which is being loaded on document ready event through an AJAX call. Now in my object, i am not getting this content.

How can i get such content which are loaded through ajax.

Thanks in advance.
Posted

Ajax calls require a javascript VM to run. You will not be able, using .Net WebRequest objects, to get the Ajax result as you will not be able to execute the Javascript for the document without linking a Javascript VM to a DOM management framework. A.k.a a Browser.

You have three options.

Try and write code which looks at the pages javascript and allows you to emulate the AJAX call an integrate the content. But this is not a nice way of doing it and any change to a page could complete throw off your code.

Fiddler is a tool which implements a man-in-the-middle process and logs all requests and responses, including AJAX. You could browser the site with this and recode the results. I'm not sure how Fiddler achieves what it does but you could aim to write a similar process.

The better option is to use the .Net WebBrowser control. You can use this control to access the current page text. Load the page wait long enough for the AJAX to complete and then get the content from the browser control.
 
Share this answer
 
Hi Stephen
Thanks for your reply but i tried that web browser stuff already...(nd its the only thing which i can implement in my scenario)
Now i placed a huge delay like 1000000 but still ajax content is not coming that is why i had to come here... :(
 
Share this answer
 
Comments
Tomas Takac 16-Mar-15 4:40am    
Comment on the respective solution, do not post your reply as an solution. Please use "Have a Question or Comment?" button to comment on Solution #1 and delete this one.
I have tried one more thing...
i guess this one is working for me...

I took help of selenium and it did the thing for me.. :)
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900