Skip to content Skip to sidebar Skip to footer

How To Save Complete Html Page With Frames/iframes Included?

During the web scraping I want to save current page's html to a file for later debug. browser.html helps in most cases, but when the page contains an iframe/frame, it's content is

Solution 1:

Frames act much like a completely separate web page, and while you can see the content as it appears in the rendered document and the dom, contents of a frame are not technically part of the html for a page. You can see this in the browser, right click the main doc and view html, then compare that to what you get right clicking content that is in a frame and viewing html.

To write all the html out to files, you are likely going to need to make a method that writes out html of a frame, looks for other frames, and calls the same method recursively on any frames found inside.

Alternativly maybe look at a gem like nokogiri that is designed to parse html, it might have better methods for this sort of thing, or existing examples for how to do what you want

Post a Comment for "How To Save Complete Html Page With Frames/iframes Included?"