Advertisement
Guest User

CBSE 12th Results Scrapper

a guest
May 30th, 2015
399
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.90 KB | None | 0 0
  1. <?php
  2.  
  3. # Code By: Mudit Grover
  4.  
  5. function get_string_between($string, $start, $end){
  6.     $string = " ".$string;
  7.     $ini = strpos($string,$start);
  8.     if ($ini == 0) return "";
  9.     $ini += strlen($start);
  10.     $len = strpos($string,$end,$ini) - $ini;
  11.     return substr($string,$ini,$len);
  12. }
  13.  
  14. $raw = file_get_contents('roll.txt');
  15. $rawline = preg_split('/\r\n|\r|\n/', $raw);
  16. foreach($rawline as $rawlinedata){
  17.  
  18. $url = 'http://cbseresults.nic.in/class12/cbse122015_all.asp';
  19. $myvars = 'regno=' . $rawlinedata;
  20.  
  21. $ch = curl_init( $url );
  22. curl_setopt( $ch, CURLOPT_POST, 1);
  23. curl_setopt( $ch, CURLOPT_POSTFIELDS, $myvars);
  24. curl_setopt( $ch, CURLOPT_FOLLOWLOCATION, 1);
  25. curl_setopt( $ch, CURLOPT_HEADER, 0);
  26. curl_setopt($ch, CURLOPT_REFERER, 'http://cbseresults.nic.in/class12/cbse122015_all.htm');
  27. curl_setopt( $ch, CURLOPT_RETURNTRANSFER, 1);
  28.  
  29. $response = curl_exec( $ch );
  30.  
  31. echo $response;
  32.  
  33. }
  34. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement