I am trying to load processed webpage into string, but seems like it is loading javascript as well; but I want this to be “the final” result that can he saved to static html file and run offline.
This is what I am doing at this moment
HttpWebRequest request = (HttpWebRequest)WebRequest.Create(textBox9.Text);
IWebProxy theProxy = request.Proxy;
if (theProxy != null)
{
theProxy.Credentials = CredentialCache.DefaultCredentials;
}
request.UseDefaultCredentials = true;
request.Proxy = WebRequest.DefaultWebProxy;
// execute the request
HttpWebResponse response = (HttpWebResponse)
request.GetResponse();
// we will read data via the response stream
Stream resStream = response.GetResponseStream();
Any suggestions?
If I understand your post correctly, you don’t want to strip the javascript out of the page, but keep it and make it so that it will execute just as though you had visited the page normally in a browser?
This is kind of a notoriously hard problem for proxies to overcome, and others have done it with varying degrees of success. Javascript that is embedded in the page should run just fine, but you will run into problems running any javascript that is loaded into a page from an external file.
One thing you could try is to rewrite the paths to external javascript libraries to reflect a local path, then grab copies of those javascript files over the network as well and store everything in a mimicked directory structure. Your milage may vary based on how fancy the javascript involved is, e.g. some ajax calls probably won’t work no matter what you do.