0

I writing some scraping script on casperjs/phantomjs and trying to get html from one of goodle ads iframe tags and getting error

Code:

iframe_node = $('iframe').contents().find('iframe[name^="google_ads_frame"]')[0]
html = a.contentDocument.body.innerHTML

Error:

Uncaught DOMException: Failed to read the 'contentDocument' property from 'HTMLIFrameElement': 
Blocked a frame with origin "http://example.com" from accessing a cross-origin frame.(…)
John Doe
  • 11
  • 1
  • 1
    You can change the context to the iframe from CasperJS like [this](http://stackoverflow.com/a/14154214/1816580) and get the content from `casper.getHTML()` – Artjom B. Nov 08 '15 at 16:46

1 Answers1

0

Try changing the following variables for web-security, ssl-errors, and ssl-protocol:

casperjs --web-security=false --ignore-ssl-errors=true --ssl-protocol=any <your_script>.js

You cannot access cross-origin frames without adjusting these variables due to security settings. This should allow you to enter the frames and grab the necessary content.

oikun
  • 13
  • 4