Skip to content

Instantly share code, notes, and snippets.

@navinpai
Created August 14, 2011 22:23
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save navinpai/1145390 to your computer and use it in GitHub Desktop.
Save navinpai/1145390 to your computer and use it in GitHub Desktop.
PHP Curl script to get results of all students from Goa University site
<?php
//Stupid Univ. didn't release results, instead each student had to enter seat number to get his result!
// Wrote this script to automate the process and get the results of students from Seat No. 1-999 (Think that's the
// complete range of seat numbers)
// You end up with a seatno.html files for all seat nos in the range 1-999 ... Result of seat no. 'a' is 'a.html'
// Ran this on Ubuntu running LAMPP and it worked as expected! Nothing platform specific, so should work for you too!
// Edit if you need to find results of another semester (or if u are disgusted by the shitty code I've written and
//want to improve the code!)
$id = '4'; //Was a hidden field... Dunno what it is for
$cmbsem = '6'; // Semester number ... Change to get results of other sems
$rtype = 'E'; // Guess this means Engineering ... Again, was a hidden field
for ($i=213;$i<1000;$i++){
$txtseatno= $i; //Seat number of course
$curlPost = 'id=' . urlencode($id) . '&cmbsem=' . urlencode($cmbsem) . '&rtype=' . urlencode($rtype) . '&txtseatno=' . urlencode($txtseatno). '&SUBMIT=Send';
//GOD BLESS CURL! :)
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, 'http://unigoa.ac.in/resultdisplay.php');
curl_setopt($ch, CURLOPT_HEADER, 1);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $curlPost);
$data = curl_exec($ch);
//Just stripping away the unwanted info.. Yes, this is inefficient! :(
$first=strpos($data,'Engineering Results May 2011');
$actdata=substr($data,$first,100000);
list($actdat,$actdat2)=explode('Search',$actdata);
//Writes to SeatNo.html
$fp = fopen($i.'.html', 'w');
fwrite($fp,$actdat);
echo $txtseatno;
//Stupid Univ. site gives errors sometimes, so havta keep this as well!
if ($data = NULL)
echo 'FAILURE';
//Tying up loose ends
fclose($fp);
curl_close($ch);
}
?>
<!--Impromptu display page for results... Simply gives a list of seat nos, linked to the respective seatno.html page...
Yes, this is basically shit! :P
-->
<html>
<head>
<title>RESULTS OF 6th SEMESTER EXAMS | May 2011</title>
</head>
<body>
<!--If you're reading this, you are a geek!
Greetz from Navin Pai! :) -->
<div align="center">
<h2>CLICK ON THE SEAT NUMBER FOR RESULT</h2><br/>
<h4>Results are of Sem 6(Revised Course) May 2011 Examinations</h4><br/><br/>
<?php
for($i=1;$i!=1000;$i++){
if ($i<10)
echo "&nbsp;&nbsp;";
if ($i>9 && $i <100)
echo "&nbsp;";
echo "<a href=";
echo $i;
echo ".html>";
echo $i;
echo "</a>&nbsp;&nbsp;&nbsp;";
if ($i<10)
echo "&nbsp;&nbsp;";
if ($i>9 && $i <100)
echo "&nbsp;";
if($i%9 == 0)
echo "<br/>";
}
?>
<br/><br/>
<footer>Insert cool footer info here! :) </footer>
<h6>&copy; &nbsp; <a title="The Robot Ain't Dead Yet">R[o]b[o]Zombie Productions</a> (The cool shit you see)<br/>
and <a href="http://unigoa.ac.in">Goa University</a> (The actual results)
</h6></div>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment