public function getIdFromSource($RunID) { //Get Source $curl = curl_init("http://acm.hdu.edu.cn/viewcode.php?rid=" . $RunID); curl_setopt($curl, CURLOPT_HEADER, 0); curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1); curl_setopt($curl, CURLOPT_COOKIEFILE, $this->cookie_file); $src = curl_exec($curl); $th = new HTMLParser(); $th->loadHTML($src); return $th->innerHTML('//<ID>', '</ID>'); }
public function getIdFromSource($RunID) { //Infomation $cookie_file = tempnam("./cookie", "cookie"); $login_url = "http://poj.org/login"; $post_fields = "user_id1=" . $this->user . "&password1=" . $this->pass . "&url=/"; //Login $curl = curl_init($login_url); curl_setopt($curl, CURLOPT_HEADER, 0); curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1); curl_setopt($curl, CURLOPT_COOKIEJAR, $cookie_file); curl_setopt($curl, CURLOPT_POST, 1); curl_setopt($curl, CURLOPT_POSTFIELDS, $post_fields); $this->data = curl_exec($curl); //Get Source $curl = curl_init("http://poj.org/showsource?solution_id=" . $RunID); curl_setopt($curl, CURLOPT_HEADER, 0); curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1); curl_setopt($curl, CURLOPT_COOKIEFILE, $cookie_file); $src = curl_exec($curl); @unlink($cookie_file); $th = new HTMLParser(); $th->loadHTML($src); return $th->innerHTML('//<ID>', '</ID>'); }
public function getIdFromSource($RunID) { $cookie_file = tempnam("./cookie", "cookie"); $this->cookie_file = $cookie_file; $login_url = "http://acm.hdu.edu.cn/userloginex.php?action=login"; $post_fields = "username="******"&userpass="******"&login=Sign In"; //Login $curl = curl_init($login_url); curl_setopt($curl, CURLOPT_HEADER, 0); curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1); curl_setopt($curl, CURLOPT_COOKIEJAR, $cookie_file); curl_setopt($curl, CURLOPT_POST, 1); curl_setopt($curl, CURLOPT_POSTFIELDS, $post_fields); $this->data = curl_exec($curl); //Get Source $curl = curl_init("http://acm.hdu.edu.cn/viewcode.php?rid=" . $RunID); curl_setopt($curl, CURLOPT_HEADER, 0); curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1); curl_setopt($curl, CURLOPT_COOKIEFILE, $this->cookie_file); $src = curl_exec($curl); $th = new HTMLParser(); $th->loadHTML($src); return $th->innerHTML('//<ID>', '</ID>'); }