[英]Fetch some data from webpage And store the datas into json file using php or node.js
我在http://www.dndstatus.com/dnd-check-process.php上输入了一些电话号码,提交后会显示 DND 状态、网络运营商和电信圈等详细信息。 我想从结果网页( http://www.dndstatus.com/dnd-check-process.php?num=9721395967 )中获取这些详细信息并存储到 json 文件中。 我怎样才能做到这一点??
/* gets the data from a URL */
function get_data($url) {
$ch = curl_init();
$timeout = 5;
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, $timeout);
$data = curl_exec($ch);
curl_close($ch);
return $data;
}
$strDetails = get_data("http://www.dndstatus.com/dnd-check-process.php?num=9721395967");
或者,您可以远程使用file_get_contents
函数,但许多主机不允许这样做。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.