1

How can I get the source of a webpage that is currently running in an instance of firefox using delphi ? I would like to do this without making firefox the active window first if that is possible but just grabbing the source is my primary question.

TIA, Dave

Mogsdad
  • 44,709
  • 21
  • 151
  • 275
Dave
  • 11
  • 2
  • What do you intend to do if there's multiple Firefoxes running? – Pekka Nov 01 '10 at 09:56
  • The way I figured it would works is that I would grab the windows title of the page I am interested in and then only deal with that one page. In fact it's just 1 page that I need to get the source for anyway so that sounds like the logical way to do it to me. – Dave Nov 01 '10 at 10:04
  • Öhhh... Why not just download the source file? Why do you need to go through Firefox? – Andreas Rejbrand Nov 01 '10 at 11:53
  • Because the page is protected and the downloaded version is not the same as the version shown in firefox (which is the version I need) – Dave Nov 01 '10 at 12:01
  • 1
    Dave, it looks like you have the [same problem as somebody yesterday](http://stackoverflow.com/questions/4062766/problem-getting-html-source-from-a-protected-webpage-with-indy-delphi-7). He has the right idea. – Rob Kennedy Nov 01 '10 at 17:12

2 Answers2

2

This might help

How to embed a browser object, other than IE<n>, in a Delphi application

This is about embedding firefox (amongst others) but has lnks to other pages that shows methods that you can navigate the DOM with.

I'd look at using IE if possible it's fairly well documented how to do this in IE.

Community
  • 1
  • 1
daven11
  • 2,905
  • 3
  • 26
  • 43
  • I already have this done using the embedded IE instance that delphie uses and have run into numerous problem (mainly authentication related) so I would rather not go that route unless there is another way. Also you mention that this is fairly well documented in IE which I am assuming by "this" you are referring to my original question, so if you have any sources where I can do this using IE instead of firefox then I would rather give that a shot. – Dave Nov 01 '10 at 12:18
  • I have some source somewhere where I walked over the dom in an external ie browser, I'll try and dig it up for you, it might take a day or so if you can wait. – daven11 Nov 01 '10 at 12:43
  • Get the IHTMLDocument2 as detailed here http://www.delphigroups.info/2/12/492347.html the you can get the html from the interface if you need more details let me know – daven11 Nov 01 '10 at 13:08
0

Obligatory "here's one way, but don't do it" from the ClipBoard guy....

One ugly hack I've seen is to send keystrokes to the app and force it to copy/paste the data to the clipboard. Don't go down this road. It will work, for you, in a controlled environment. It won't work for your users, who will experience compatibility issues, unexpected trashing of their clipboard data, and crashes from other apps that are monitoring the clipboard for updates.
And no, you cannot save/restore the clipboard without causing even more trouble.

Chris Thornton
  • 15,620
  • 5
  • 37
  • 62
  • I had no intentions of doing that. I have a few ideas I am entertaining like dynamically creating the embedded WB component and then grabbing the info I need and then freeing it again so it grabs a fresh copy of the web page each time it's created. This is just a theory tho because I do not know how to create the methods I need to access the data I want a runtime. If the embdded WB did not fight me every step of the way I would had this all done long ago. – Dave Nov 01 '10 at 14:08