国产av日韩一区二区三区精品,成人性爱视频在线观看,国产,欧美,日韩,一区,www.成色av久久成人,2222eeee成人天堂

? ???? ????? PHP ? ??? ?? ???? ???

????? ???? ??? ? get ???? ???? ?? ???? ???? ? ??? ??? ?????.

?? ??? get??? ???? ?? ???? ??? ???? ? ????. URL? ???? ??? ????? ???? ??? ????? HTML ??? ??? ? ????. ??? ??? ????.

function get($url) {
    //初使化curl
    $ch = curl_init();
    //請求的url,由形參傳入
    curl_setopt($ch, CURLOPT_URL, $url);
    //將得到的數(shù)據(jù)返回
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
    //不處理頭信息
    curl_setopt($ch, CURLOPT_HEADER, 0);
    //連接超過10秒超時
    curl_setopt($ch, CURLOPT_TIMEOUT, 10);
    //執(zhí)行curl
    $output = curl_exec($ch);
    //關(guān)閉資源
    curl_close($ch);
    //返回內(nèi)容
    return $output;
}

?? NetEase?? ??? ???? ??? URL? ???? ?? ??? get ???? ?????.

?? get ???? ???? URL? ??? ? ????. ? URL? ???? ????? HTML? ?????.

???? ??? New Media Observation Network? ?? ?? ??????: http://www.xmtnews.com/events.

??? ?? ??:

1.png

1. ??? ??? html? ?????.

? ??? ?? HTML ??? ?????.

<section class="ov">

? ?? ??? ????.

<div class="hr-10"></div>

preg_match? ???? ???? ???? ?? ???? ?????. ??? ?? ??? HTML???. ???? HTML? $area ??? ?????.

? ???? ???? ??? ????.

<section class="ov">(.*?)<div class="hr-10"><\/div>/mis'

2. ??? ??

??? ?? ??? <h3> ??? ??? ??????. preg_match_all? ???? ???? ?????.

preg_match_all('/<h3><a href="(.*?)" title=".*?" class="headers" target="_blank">(.*?)<\/a><\/h3>/mis', $area, $find);

url? ??? ???? ??? $find? ?? $find ??? ???? ???? ??? ? ? ????.

??? ?? ???? ? ?? ??? ? ?? URL? ?? ??? ?? ????.

?? ?? ??? ??? ????:

<?php

$content = get('http://www.xmtnews.com/events');

preg_match('/<section class="ov">(.*?)<div class="hr-10"><\/div>/mis', $content, $match);

//將正則匹配到的內(nèi)容賦值給$area
$area = $match[1];

preg_match_all('/<h3><a href="(.*?)" title=".*?" class="headers" target="_blank">(.*?)<\/a><\/h3>/', $area, $find);


var_dump($find);

function get($url) {

   //初使化curl
   $ch = curl_init();

   //請求的url,由形參傳入
   curl_setopt($ch, CURLOPT_URL, $url);

   //將得到的數(shù)據(jù)返回
   curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);

   //不處理頭信息
   curl_setopt($ch, CURLOPT_HEADER, 0);

   //連接超過10秒超時
   curl_setopt($ch, CURLOPT_TIMEOUT, 10);

   //執(zhí)行curl
   $output = curl_exec($ch);

   //關(guān)閉資源
   curl_close($ch);

   //返回內(nèi)容
   return $output;
}
?>


???? ??
||
<?php $content = get('http://www.xmtnews.com/events'); preg_match('/<section class="ov">(.*?)<div class="hr-10"><\/div>/mis', $content, $match); //將正則匹配到的內(nèi)容賦值給$area $area = $match[1]; preg_match_all('/<h3><a href="(.*?)" title=".*?" class="headers" target="_blank">(.*?)<\/a><\/h3>/', $area, $find); var_dump($find); function get($url) { //初使化curl $ch = curl_init(); //請求的url,由形參傳入 curl_setopt($ch, CURLOPT_URL, $url); //將得到的數(shù)據(jù)返回 curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); //不處理頭信息 curl_setopt($ch, CURLOPT_HEADER, 0); //連接超過10秒超時 curl_setopt($ch, CURLOPT_TIMEOUT, 10); //執(zhí)行curl $output = curl_exec($ch); //關(guān)閉資源 curl_close($ch); //返回內(nèi)容 return $output; } ?>