Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- $user_info = file_get_html('https://www.codechef.com/users/tarango_khan')->plaintext;
- $user_info = "User Info of the user is: ".$user_info;
- echo $user_info;
- $start_pos1 = strpos ($user_info , "Successfully Solved:") + 23;
- $last_pos1 = strpos ( $user_info , "Problems Partially Solved");
- $Len1 = $last_pos1 - $start_pos1;
- $problem_list = substr($user_info, $start_pos1 , $Len1-1);
- $problem_list = trim($problem_list);
- $problem_list = preg_replace('/\s+/', ' ', $problem_list);
- $problem_list = mysql_real_escape_string( $problem_list);
- //echo "<br>Problem List : ".$problem_list."<br>";
- $Size = strlen($problem_list);
- $val = "";
- $contest = array();
- $problems = array();
- $c1 = 0;
- $c2 = 0;
- for($i = 0;$i<$Size;$i++){
- $ch = substr($problem_list, $i , 1);
- if(strcmp($ch, " ") == 0){
- if(strlen($val) == 0) continue;
- $problems[$c2] = $val;
- $val = "";
- $c2++;
- }else if(strcmp($ch, ",") == 0){
- if(strlen($val) == 0) continue;
- $problems[$c2] = $val;
- $val = "";
- $c2++;
- }else if(strcmp($ch, ":") == 0){
- if(strlen($val) == 0) continue;
- $contest[$c1] = $val;
- $val = "";
- $c1++;
- }else{
- $val = $val.$ch;
- }
- }
- if(strlen($val) != 0){
- $problems[$c2] = $val;
- }
- echo "Participated in Contests: ";
- foreach ($contest as &$value) {
- echo $value." ";
- }
- echo "<br>";
- echo "List of Solved Problems: ";
- foreach ($problems as &$value) {
- echo $value." ";
- }
- echo "<br>";
- ?>
Advertisement
Add Comment
Please, Sign In to add comment