0

//変更を加えましたが、preg_match関数が機能せず、Workをエコーし​​ます。何が悪いのか理解できません。私はおかしくなりそうだ

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;
}
4

2 に答える 2

1

curl_downloadから値を返してみてください。return ステートメントはありません。

于 2012-10-16T18:36:01.677 に答える
0

問題は、echo $ categoryPageDom-> find('div#pagination a.gh'、1)->attr['href'];を作成したときのURLに関連していました。ブラウザでこのhttp://www.xxxx.de/xxxxxxxxxxxxxxx=iw&artikel=101&detail=makのようなものが表示されます。しかし、ソースコードを見ると、次のようになっていますhttp://www.xxxx.de/xxxxxxxxxxxxxxx=iw& * amp; * artikel = 101&* amp; * detail=mak問題はampでした。str_replaceを使用して削除しました。カールは非常にうまく機能します

于 2012-10-25T05:35:41.830 に答える