Advertisement
Guest User

Untitled

a guest
Feb 5th, 2016
176
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.29 KB | None | 0 0
  1. <?php
  2.     require_once('../lib/Requests/library/Requests.php');
  3.     require_once('../lib/simple_html_dom.php');
  4.     Requests::register_autoloader();
  5.    
  6.    
  7.     function beginSesion() {
  8.         global $session;
  9.         try {
  10.             $auth = array(
  11.                 'main_login' => '4523023966',
  12.                 'main_password' => '9WQZ',
  13.                 'verify' => false
  14.             );
  15.             $session = new Requests_Session('http://edu.tatar.ru/');
  16.             $session->post('http://edu.tatar.ru/logon', array(), $auth);
  17.             return(true);
  18.         }
  19.         catch(Exception $e) {
  20.             echo $e->getMessage();
  21.             return(false);
  22.         }
  23.     }
  24.    
  25.     function getHtml($timestamp) {
  26.         global $session;
  27.         global $html;
  28.         try{
  29.             //$timestamp-=10800;    //gmt to local
  30.             $request = $session->get('http://edu.tatar.ru/user/diary/day?for='.$timestamp);
  31.             $html=str_get_html($request->body);
  32.             return true;
  33.         }
  34.         catch(Exception $e) {
  35.             echo $e->getMessage();
  36.             return(false);
  37.         }
  38.     }
  39.    
  40.     function getDay()
  41.     {
  42.         global $html;
  43.         global $marks;
  44.         global $tasks;
  45.        
  46.         foreach($html->find('table.main tbody tr[style="text-align: center;"]') as $tr)
  47.         {
  48.             $subj = str_replace(" ", "", $tr->find('td', 1)->plaintext);
  49.             $tasks[$subj] = $tr->find('td', 2)->plaintext;
  50.            
  51.             foreach($tr->find('table.marks td') as $mark)
  52.             {
  53.                 $mark = $mark->plaintext;
  54.                 $marks[$subj][]=$mark;
  55.             }
  56.         }
  57.     }
  58. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement