如何使用php编写查询快递信息的类.php?
- 内容介绍
- 相关推荐
本文共计544个文字,预计阅读时间需要3分钟。
php查询快递信息的类.php expressname=$this->expressname();收集网页内容的函数private function getcontent($url) { if (function_exists(file_get_contents)) { $file_contents=file_get_contents($url); } else { $ch=curl_init(); $time=curl_setopt($ch, CURLOPT_URL, $url); $time=curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); $time=curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true); $file_contents=curl_exec($ch); curl_close($ch); }}
php查询快递的类.php
expressname = $this->expressname();
}
/*
* 采集网页内容的方法
*/
private function getcontent($url){
if(function_exists("file_get_contents")){
$file_contents = file_get_contents($url);
}else{
$ch = curl_init();
$timeout = 5;
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt ($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt ($ch, CURLOPT_CONNECTTIMEOUT, $timeout);
$file_contents = curl_exec($ch);
curl_close($ch);
}
return $file_contents;
}
/*
* 获取对应名称和对应传值的方法
*/
private function expressname(){
$result = $this->getcontent("www.kuaidi100.com/");
preg_match_all("/data\-code\=\"(?P
本文共计544个文字,预计阅读时间需要3分钟。
php查询快递信息的类.php expressname=$this->expressname();收集网页内容的函数private function getcontent($url) { if (function_exists(file_get_contents)) { $file_contents=file_get_contents($url); } else { $ch=curl_init(); $time=curl_setopt($ch, CURLOPT_URL, $url); $time=curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); $time=curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true); $file_contents=curl_exec($ch); curl_close($ch); }}
php查询快递的类.php
expressname = $this->expressname();
}
/*
* 采集网页内容的方法
*/
private function getcontent($url){
if(function_exists("file_get_contents")){
$file_contents = file_get_contents($url);
}else{
$ch = curl_init();
$timeout = 5;
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt ($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt ($ch, CURLOPT_CONNECTTIMEOUT, $timeout);
$file_contents = curl_exec($ch);
curl_close($ch);
}
return $file_contents;
}
/*
* 获取对应名称和对应传值的方法
*/
private function expressname(){
$result = $this->getcontent("www.kuaidi100.com/");
preg_match_all("/data\-code\=\"(?P

