Ejemplo n.º 1
0
        // 헤더 출력 여부
        curl_setopt($ch, CURLOPT_POST, 1);
        // Post Get 접속 여부
        curl_setopt($ch, CURLOPT_POSTFIELDS, "var1=str1&var2=str2");
        // Post 값 Get 방식처럼적는다.
        curl_setopt($ch, CURLOPT_TIMEOUT, 30);
        // TimeOut 값
        curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
        // 결과값을 받을것인지
        $this->buffer = curl_exec($ch);
        curl_close($ch);
    }
    function result()
    {
        //한자
        preg_match_all("/\\<span\\>\\[(.*)\\]/", $this->buffer, $match);
        //히라가나
        preg_match_all("/event\\)\\;\"\\>(.*)\\[/", $this->buffer, $matches);
        for ($i = 0; $i < count($match[1]); $i++) {
            static $tmp = 0;
            $voca[$tmp]['v1'] = $matches[1][$i];
            $voca[$tmp]['v2'] = $match[1][$i];
            $tmp++;
        }
        print_r($voca);
    }
}
$exam = new mission();
$exam->get_content("http://jpdic.naver.com/jlpt/level-1/parts-0/p1.nhn");
$exam->result();