0
我写上casperjs/phantomjs一些刮脚本,并试图从goodle广告的iframe代码的一个HTML内容和获取错误获取HTML代码的iframe - “无法读取contentDocument”错误
代码:
iframe_node = $('iframe').contents().find('iframe[name^="google_ads_frame"]')[0]
html = a.contentDocument.body.innerHTML
错误:
Uncaught DOMException: Failed to read the 'contentDocument' property from 'HTMLIFrameElement':
Blocked a frame with origin "http://example.com" from accessing a cross-origin frame.(…)
您可以将CasperJS的上下文从[this](http://stackoverflow.com/a/14154214/1816580)更改为iframe的内容,并从casper.getHTML() –