我一直在玩使用 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 中?