我正在尝试从许多 iframe 中提取一些链接属性(文本、href)。
源代码:
<iframe width="120" height="600" frameborder="0" marginwidth="0" marginheight="0" vspace="0" hspace="0" allowtransparency="true" scrolling="no" onload="var i=this.id,s=window.google_iframe_oncopy,H=s&&s.handlers,h=H&&H[i],w=this.contentWindow,d;try{d=w.document}catch(e){}if(h&&d&&(!d.body||!d.body.firstChild)){if(h.call){setTimeout(h,0)}else if(h.match){w.location.replace(h)}}" id="aswift_0" name="aswift_0" style="left:0;position:absolute;top:0;"></iframe>
内部文档(iframe)
<html>
<head>
<script type="text/javascript" src="http://pagead2.googlesyndication.com/pagead/osd.js"></script>
</head>
<body marginwidth="0" marginheight="0">
<iframe width="120" height="600" frameborder="0" marginwidth="0" marginheight="0" vspace="0" hspace="0" allowtransparency="true" scrolling="no" style="display:none" id="zrt_ads_frame1" name="zrt_ads_frame1" src="http://googleads.g.doubleclick.net/pagead/html/r20130628/r20130206/zrt_lookup.html">
</iframe>
<script>google_ad_client="pub-6276736854";google_ad_height=600;google_ad_slot="6197230xxx";google_ad_width=120;google_loader_used="sa";google_show_ads_impl=true;google_unique_id=1;google_async_iframe_id="aswift_0";google_ad_unit_key="212";google_start_time=1372933145673;google_ad_handling_experiment="PC";google_bpp=5;</script>
<script src="http://pagead2.googlesyndication.com/pagead/js/r20130628/r20130206/show_ads_impl.js">
</script>
<script src="http://pagead2.googlesyndication.com/pagead/expansion_embed.js">
</script>
<script>google_protectAndRun("ads_core.google_render_ad", google_handleError, google_render_ad);</script>
<iframe allowtransparency="true" frameborder="0" height="600" hspace="0" id="google_ads_frame1" marginheight="0" marginwidth="0" name="google_ads_frame1" scrolling="no" src="http://googleads.g.doubleclick.net/pagead/ads?client=ca-pub-627673xx&output=html&h=600&slotname=6197230276&w=120&lmt=1372922345&flash=11.7.700&url=http%3A%2F%2Fahehl%2Falgeex.php&dt=1372933145673&bpp=5&bdt=526&shv=r20130628&cbv=r20130206&saldr=sa&correlator=1372933145804&frm=20&adk=3222528636&ga_vid=1998811959" style="left:0;position:absolute;top:0" vspace="0" width="120"></iframe>
</body>
</html>
问题是我无法从 jQuery 访问第二个 iFrame。
我试过了:
$(document).ready(function(){
$('iframe').contents().find("html").html();
});
但它只输出我这个:
<iframe width="120" height="600" frameborder="0" marginwidth="0" marginheight="0" vspace="0" hspace="0" allowtransparency="true" scrolling="no" style="display:none" id="zrt_ads_frame1" name="zrt_ads_frame1" src="http://googleads.g.doubleclick.net/pagead/html/r20130628/r20130206/zrt_lookup.html"></iframe>
<script>google_ad_client="pub-6276736854";google_ad_height=600;google_ad_slot="6197230xxx";google_ad_width=120;google_loader_used="sa";google_show_ads_impl=true;google_unique_id=1;google_async_iframe_id="aswift_0";google_ad_unit_key="212";google_start_time=1372933145673;google_ad_handling_experiment="PC";google_bpp=5;</script>
<script src="http://pagead2.googlesyndication.com/pagead/js/r20130628/r20130206/show_ads_impl.js"></script>
没有包含所有数据的第二个 iframe。
我什至试着做 find ('script').remove()
。但什么都没有。
有什么建议么?
多谢你们。