views:

270

answers:

2

Using WWW::Mechanize::Firefox, I can get the source of the page I visited. However, if the page contains a frame, I get the frame tag and not the actual source of the page that is loaded. Mechanize::Frames seems to be what I am looking for. Is there a way to use them together?

+4  A: 

That's probably because you're not loading the frame contents.

$mech->follow_link(tag => "frame"); # open first frame in document
my $src = $mech->content;
Zano
Firebug with Expect Element will show the source of a page after javascript renders everything and will physically put the source code from the frames and iframes into the source from the main page where the frame or iframe appeared. That's what I am looking to get. I want to be able to pass in a list of URLs, then have WWW::Mechanize::Firefox load the page, do all the javascript, and then return the final, rendered source. It's looking like that isn't possible.For some reason, when I do the follow_link, it goes back to the same page. However, on the first load, not all the js has finished.
SJaguar13
A: 

To get at the frame HTML source, just get that frame through ->selector() or ->xpath() and then use $frame->{innerHTML}.

Corion