我一直在玩使用jQuery簡單的屏幕刮板的想法,我想知道如果以下是可能的。簡單的屏幕使用jQuery刮刮
我有簡單的HTML網頁和我進行嘗試(如果可能的話),以抓住所有的列表項的內容從另一頁,像這樣:
主頁:
<!-- jQuery -->
<script type='text/javascript'>
$(document).ready(function(){
$.getJSON("[URL to other page]",
function(data){
//Iterate through the <li> inside of the URL's data
$.each(data.items, function(item){
$("<li/>").value().appendTo("#data");
});
});
});
</script>
<!-- HTML -->
<html>
<body>
<div id='data'></div>
</body>
</html>
其他網頁:
//Html
<body>
<p><b>Items to Scrape</b></p>
<ul>
<li>I want to scrape what is here</li>
<li>and what is here</li>
<li>and here as well</li>
<li>and append it in the main page</li>
</ul>
</body>
那麼,是不是可能使用jQuery從外部頁面提取所有列表項內容並將它們追加到div內?
也可以在JavaScript中獲取當前頁面的文本(無標籤):http://stackoverflow.com/questions/5321739/how-can-i-get-the-text-only- no-tags-from-a-html-document – 2013-02-20 18:28:08