2012-07-09 24 views
1

我需要做的是我想要一本关于谷歌图书的书。 一本书的每一页都通过AJAX进入。但谷歌提供的iframe太 这是一个iframe中的我期待的如何抓取Iframe内的所有内容?

<iframe id="iframeId" frameborder="0" scrolling="no" style="border:0px" src="http://books.google.com.pk/books?id=KOrTwnwcJ9IC&lpg=PP1&dq=magento%20books&pg=PT36&output=embed" width=500 height=500></iframe> 

我想grabe这本书的所有内容,把它放在一些股利和比它。我做的PDF文件可以做,但我只是不能抢内容

我想这不能不说ID没有在一部开拓创新的iframe标签定义

<Script type="text/javascript"> 

    var doc; 
if (document.getElementById(iframeId).contentDocument) { 
    doc = document.getElementById(iframeId).contentDocument; 
} 
else if (document.getElementById(iframeId).contentWindow) { // older IE 
    doc = document.getElementById(iframeId).contentWindow.document 
    } 

if (doc) { alert(doc.body.innerHTML) } 

</script> 

有没有ID,这样比我手动写iframe标签是ID ID =” iframeId“ 但没有任何想法?

回答

1

只要在iframe加载的页面是在同一个域中,你可以有这样的:

var myIFrame = document.getElementById(iFrameName); 
var content = myIFrame.contentWindow.document.body.innerHTML; 

但谷歌还提供了JSON格式从谷歌文档retrieveng信息支持:

https://developers.google.com/gdata/samples/spreadsheet_sample?hl=ro

而第二个可能是你在找什么。

+0

让我在JSON BTW THANX上进行研发 – 2012-07-09 08:58:36