Tutorial :How to run javascript function from external site C#



Question:

I would like to download an image from external site using C#. The problem is image's source is generated on the server side using ajax and is not available from source code of the page. The JavaScript function which is called to generate image's source looks like this:

xmlHttp.onreadystatechange=function()    {    if(xmlHttp.readyState==4)      {      document.searchform.xpic.src=xmlHttp.responseText;      }    }  

xmlHttp is instanced earlier:

xmlHttp=new XMLHttpRequest();  

So is it possible to initiate the call of JavaScript function and get source of the image? Could you please tell me how to do it?


Solution:1

You could inspect the URL by which the above request is made and replicate the same request from your C# code to get the URL of the images. Its much easier to go on about the problem this way than looking at executing JavaScript within the C# environment.


Note:If u also have question or solution just comment us below or mail us on toontricks1994@gmail.com
Previous
Next Post »