gpt4 book ai didi

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

转载 作者:行者123 更新时间:2023-12-03 10:17:01 24 4
gpt4 key购买 nike

你好,我发现了这个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/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com