JEV
JEV

Reputation: 2504

Retrieve current page in Internet Explorer using C#

I am currently looking for a solution to a problem I have. My aim is to be able to get the Source code of HTML pages that have been looked at. Originally I was going to just go through the history of IE and then get the source code for every visited site, however this isn't feasible at the moment, and I am looking for a method, if possible, which would simply pull the current page that is being looked at in Internet Explorer, and pull the source code.

Is it possible that a client application could do this? Hook into Internet Explorer and grab the source code? If so, how, what references etc. Please note I am not looking to use my own Browser in the client, but rather the application Internet Explorer.

Thanks!

Internet Explorer 8 / 9.

Upvotes: 1

Views: 811

Answers (1)

Sam Axe
Sam Axe

Reputation: 33738

You can do this via two methods.

First would be an http proxy like FiddlerCore

Second would be with MSHTML (COM library: Microsoft HTML Object Library)

Dim tWindows As ShellWindows = new ShellWindows
For Each tInstance As IWebBrowser2 in tWindows
  Console.WriteLine(tInstance.LocationURL)
Next

Upvotes: 2

Related Questions