Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jquery/77.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 使用java脚本从远程网站读取html表内容_Javascript_Jquery - Fatal编程技术网

Javascript 使用java脚本从远程网站读取html表内容

Javascript 使用java脚本从远程网站读取html表内容,javascript,jquery,Javascript,Jquery,我想从远程网站读取html表数据,并使用java脚本存储在列表或数组中。如果我在远程网站上有如下html: <!DOCTYPE html> <html> <body> <table style="width:100%"> <tr> <td>Jill</td> <td>Smith</td> <td>50</td> <

我想从远程网站读取html表数据,并使用java脚本存储在列表或数组中。如果我在远程网站上有如下html:

<!DOCTYPE html>
<html>
<body>

<table style="width:100%">
  <tr>
    <td>Jill</td>
    <td>Smith</td>      
    <td>50</td>
  </tr>
  <tr>
    <td>Eve</td>
    <td>Jackson</td>        
    <td>94</td>
  </tr>
  <tr>
    <td>John</td>
    <td>Doe</td>        
    <td>80</td>
  </tr>
</table>

</body>
</html>
我希望alert alertresult显示带有内容的表,假设上面的html来自


我们不是一个代码生产工厂。。。向我们展示您到目前为止所做的尝试,并告诉我们您到底遇到了什么问题。我展示了我所做的尝试,我遇到了从远程网站获取html表数据的问题此解决方案不适用于远程网站的html表。我正在寻找一个解决方案,从远程网站的html表工程。我已经提供了这个答案。谢谢你的回答……我回答了你原来的问题,接受这个问题,用你修改过的问题再问一个问题。你不能每次我回答时都编辑你的问题。
var result;
    function xmlparser() {
        $.ajax({
            type: "GET",
            url: "http://www.example.com",
            dataType: "html",
            success: function (data) { 
                result = data.table;
                alert(result);
            },

            }
        });             
    }    
var result = []; // Create empty array
$("tr").each(function(i, el) { // iterate through all TR elements
  result.push(el.innerText.replace(/\t/g, " "));
  // no need to get each element and concat, 
  // innerText will do it if you replace tabs for spaces
});
console.log(result); // ["Jill Smith 50", "Eve Jackson 94", "John Doe 80"]