0

I want to be able to get the complete source code from a webpage, I tried the method mentioned here It does not grab all the source code for the page I want the code from.

The page got several iframes each with a "virtual tag" #document and everything after that tag I can not get.

If I just right-click the page in Chrome and select view-source the code after the #document is not visible there either. However, if I inspect the page using Chrome I can see all the source code after the #document tag too.

I looked at this post on SO but it does not help me either. I can actually see the first part of the code in the iframes, just nothing after the #document. It looks structually like this:

<iframe class="xxxxx" frameborder="0" scrolling="no" srcdoc="<html 
    <base target="_parent">
    <head>
    <style>      body { display: none; }    </style>
    </head>
    <body>
    <style>  </style>
    </body>
</html>">
#document
<!-- code I can not reach -->
<html><head></head><body>...</body></html>
</iframe>

I tried to iterate through all the iframes in DOM using javascript but then I just get a security error which from what I read can not be worked around:

SecurityError: Blocked a frame with origin "http://www.google.com" from accessing a cross-origin frame.

Is there a way to do what I want? I mean, Chrome can see this source code through the Inspect function so it must be possible in some way.

  • 1
    Run executeScript with `allFrames: true, matchAboutBlank: true` parameters so your callback will receive an array [mainPageCode, iframeCode1, iframeCode2, ...]. Refer to the documentation. – wOxxOm Sep 24 '18 at 04:54
  • Thank you, finally got it to work, now I get so much data back chrome can't handle displaying it, but i'm on to filtering the data. Please make as answer if you want me to accept it. – Andreas Toresäter Sep 24 '18 at 08:09

0 Answers0