javascript - 从特定网站获取表格内容

标签 javascript php jquery html

你好,我发现了这个WEBSITE我想获取表的内容并将其发布在我的网站上...有没有办法使用 javascript 或 php (没有 iram 或对象)来做到这一点

最佳答案

希望下面的代码可以帮助您

$html=getHTML("http://www.website.com",10);
preg_match("/<title>(.*)</title>/i", $html, $match);
$title = $match[1];

//use curl to get html content
function getHTML($url,$timeout)
{
       $ch = curl_init($url); // initialize curl with given url
       curl_setopt($ch, CURLOPT_USERAGENT, $_SERVER["HTTP_USER_AGENT"]); // set  useragent
       curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); // write the response to a variable
       curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true); // follow redirects if any
       curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, $timeout); // max. seconds to execute
       curl_setopt($ch, CURLOPT_FAILONERROR, 1); // stop when it encounters an error
       return @curl_exec($ch);
}
$html=getHTML("http://www.website.com",10);
// Find all images on webpage
foreach($html->find("img") as $element)
echo $element->src . '<br>';

// Find all links on webpage
foreach($html->find("a") as $element)
echo $element->href . '<br>';

关于javascript - 从特定网站获取表格内容,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29827639/

相关文章:

javascript - 在移动设备的谷歌地图上禁用可拖动

FireFox 中的 javascript 数组

javascript - angularjs 和范围问题(我认为)

javascript - 插入一个数组并保持数组 n 项很长

php - 无法访问 Laravel 中的存储文件夹

php - 使用大小写限制 2 查询 MySQL

javascript - 使用 JQuery on 和 off 方法附加和删除选定的事件处理程序

javascript - 将自定义对象列表从服务器发送到客户端

javascript - 引用错误: event is not defined on addEventListener()

php - 设置 cookie 并插入数据库时​​遇到问题