public function getAData()
{
$url = '要获取的url';
$cookie = 'PHPSESSID='.$cp_cookie;
$str = $this->sendRequest($url,$cookie);
$patt1 = '/<a href=\"(.*?)\" class=\"label label-success\".*?>(.*?)<\/a>/i';
preg_match_all($patt1,$str,$first_match);
$patt2 = "/>(.*)<\/a>/";
$patt3 = "/href=\"([^\"]+)/";
$arr = array();
for ($i=0;$i<count($first_match[0]);$i++) {
preg_match_all($patt2,$first_match[0][$i],$acontent);
preg_match_all($patt3,$first_match[0][$i],$ahref);
$arr[$i]['content'] = $acontent[1][0];
$arr[$i]['url'] = $ahref[1][0];
}
$data = array();
foreach ($arr as $key=>$value) {
$data[] = $value;
}
return json($data);
}
|