Tarango

Untitled

Jul 29th, 2015
390
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.47 KB | None | 0 0
  1. <?php
  2.     $user_info = file_get_html('https://www.codechef.com/users/tarango_khan')->plaintext;
  3.     $user_info = "User Info of the user is: ".$user_info;
  4.     echo $user_info;
  5.     $start_pos1 = strpos ($user_info , "Successfully Solved:") + 23;
  6.     $last_pos1 = strpos ( $user_info , "Problems Partially Solved");
  7.     $Len1 = $last_pos1 - $start_pos1;
  8.     $problem_list = substr($user_info, $start_pos1 , $Len1-1);
  9.     $problem_list = trim($problem_list);
  10.     $problem_list = preg_replace('/\s+/', ' ', $problem_list);
  11.     $problem_list = mysql_real_escape_string( $problem_list);
  12.  
  13.     //echo "<br>Problem List : ".$problem_list."<br>";
  14.  
  15.     $Size = strlen($problem_list);
  16.     $val = "";
  17.     $contest = array();
  18.     $problems = array();
  19.     $c1 = 0;
  20.     $c2 = 0;
  21.     for($i = 0;$i<$Size;$i++){
  22.         $ch = substr($problem_list, $i , 1);
  23.         if(strcmp($ch, " ") == 0){
  24.             if(strlen($val) == 0) continue;
  25.             $problems[$c2] = $val;
  26.             $val = "";
  27.             $c2++;
  28.         }else if(strcmp($ch, ",") == 0){
  29.             if(strlen($val) == 0) continue;
  30.             $problems[$c2] = $val;
  31.             $val = "";
  32.             $c2++;
  33.         }else if(strcmp($ch, ":") == 0){
  34.             if(strlen($val) == 0) continue;
  35.             $contest[$c1] = $val;
  36.             $val = "";
  37.             $c1++;
  38.         }else{
  39.             $val = $val.$ch;
  40.         }
  41.  
  42.     }
  43.     if(strlen($val) != 0){
  44.         $problems[$c2] = $val;
  45.     }
  46.  
  47.     echo "Participated in Contests: ";
  48.     foreach ($contest as &$value) {
  49.         echo $value." ";
  50.     }
  51.     echo "<br>";
  52.     echo "List of Solved Problems: ";
  53.     foreach ($problems as &$value) {
  54.         echo $value." ";
  55.     }
  56.     echo "<br>";
  57.    
  58. ?>
Advertisement
Add Comment
Please, Sign In to add comment