get source of web view

I’ve been toying with web view and was successful in getting it to load a url. Is it possible to get the source code of the url that has been loaded into the web view.

Hi,

something like this


set mainFrame to call method "mainFrame" of object (view "browser")
set dom to (call method "DOMDocument" of mainFrame)
set docElement to (call method "documentElement" of dom)
set theSource to (call method "outerHTML" of docElement)

I too am toying with web views. Can I manipulate the dom like i would do in safari?

I’m very intrigued, but don’t know quite what you mean by “web view”. Is this an app or are you using Firefox/Safari?

What kind of tell block would you wrap around those set statements?

“web view” is Class WebView in Interface Builder.
As the commands are ObjC methods, there is no application tell block needed,
maybe a reference tell block for the target window

StefanK,

Ooooh. I gotcha. I was thinking this was all just standard AppleScript. I’m not quite familiar enough with Interface Builder to implement what you’re talking about.

If you have any quick tips on how I would go about just running the code you suggested, I’d be much obliged.

(I do have the developer tools installed.)

Thanks,