PHP复制代码
function curl_get_content ( $url )
{
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL , $url); //Set access url adress
curl_setopt($ch, CURLOPT_TIMEOUT , 5); //Set timeout
curl_setopt($ch, CURLOPT_RETURNTRANSFER , 1); //Ser return value
$r = curl_exec($ch); //Set $r
curl_close($ch); //Close curl function
return $r; //Return data
}
$url="http://www.malaysiaairlines.com/content/mas/my/en/book-and-plan/flight- status/jcr:content/contentpar/flightstatussearch_0.processSearch.html/?flightdate=02/24/2013&flightfrom=MYY";
$result = curl_get_content ($url);
$pattern = '/<tbody>([^"]+)<\/tbody>/';
preg_match_all($pattern, $result, $arr);
复制代码
把CURL操作封装起来,基本上木有什麽困难。
可以参考UDSync用的方式。 |