//我做了一些改變,但preg_match功能不起作用,並回聲工作。我不明白什麼是錯的。我要瘋了PHP的回聲工作,但preg_match不起作用
public function crawl()
{
$html = $this->getPageHTMLContent($this->getDomain().$this->entryPagePath);
$categoryPageDom = $this->getHtmlDom($html);
echo $categoryPageDom->find('div#pagination a.gh', 1)->attr['href'];
preg_match("/\?p=(.*)&q/", $categoryPageDom->find('div#pagination a.gh', 1)->attr['href'], $machtes);
var_dump($machtes);
}
public function getPageHTMLContent($url){
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
$contents = curl_exec ($ch);
curl_close ($ch);
return $contents;
}
刪除此行curl_setopt($ ch,CURLOPT_FOLLOWLOCATION,true); – GBD