Created
October 10, 2015 20:03
-
-
Save samundrak/43b6560f5f2af40db437 to your computer and use it in GitHub Desktop.
Pulling SLC Result From Slc.ntc.net.np From PHP Nepali,I am trying to pull slc result from slc.ntc.net.np website from php CURL .First it make request to website and send the form data symbol number to website and we save the result as text in our server and then we show the result.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<form action="" method="post"> | |
<input type="text" name="symbol"> | |
<input type="submit" name="submit"> | |
</form> | |
<?php | |
$scrapper = new scrapper(); | |
echo $scrapper->show(); | |
class scrapper{ | |
private $symbol; | |
private $url; | |
public function __construct(){ | |
if(isset($_POST['submit'])){ | |
$this->symbol = $_POST['symbol']; | |
$this->url = "http://slc.ntc.net.np/slc2070supp.php"; | |
} | |
} | |
private static function resultExec($url,$symbol){ | |
$ch = curl_init(); | |
curl_setopt($ch, CURLOPT_URL, $url); | |
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); | |
curl_setopt($ch, CURLOPT_POST, true); | |
$data = array( | |
'symbol' => $symbol, | |
'Submit' => 'Submit' | |
); | |
curl_setopt($ch, CURLOPT_POSTFIELDS, $data); | |
$output = curl_exec($ch); | |
$info = curl_getinfo($ch); | |
curl_close($ch); | |
return $output; | |
} | |
private function writeFile(){ | |
$openFile = fopen("result.txt","w"); | |
fwrite($openFile,self::resultExec($this->url,$this->symbol)); | |
} | |
public function show(){ | |
$this->writeFile(); | |
$show = file("result.txt"); | |
return $show[79]; | |
unlink('result.txt'); | |
} | |
} | |
?> | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment