thieumao

getdemo.php

Dec 10th, 2013
123
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.98 KB | None | 0 0
  1. <?php
  2. include('../simplehtmldom/simple_html_dom.php');
  3.  
  4. // -----------------------------------------------------------------------------
  5.  
  6. // Retrieve the DOM from a given URL
  7. $link = $_GET["link"];
  8. $html = file_get_html($link);
  9.  
  10. $i=0;
  11. $timeupdate = array();
  12. foreach($html->find('span[style="font-size:14px; color:#fff; "]') as $e) {
  13.     $timeupdate[$i++] = $e->innertext;
  14. }
  15.  
  16. $i=0;
  17. $product = array();
  18. foreach($html->find('td[class="number_kq"]') as $e) {
  19.     $product[$i++] = $e->innertext;
  20. }
  21.  
  22. $response["products"] = array();
  23. for ($i=0; $i < 5; $i++) {
  24.     $kqmb["Time"]=$timeupdate[$i];
  25.     $j=$i*8;
  26.     $kqmb["DB"]=$product[$j++];
  27.     $kqmb["G1"]=$product[$j++];
  28.     $kqmb["G2"]=$product[$j++];
  29.     $kqmb["G3"]=$product[$j++];
  30.     $kqmb["G4"]=$product[$j++];
  31.     $kqmb["G5"]=$product[$j++];
  32.     $kqmb["G6"]=$product[$j++];
  33.     $kqmb["G7"]=$product[$j++];
  34.  
  35.     array_push($response["products"], $kqmb);
  36. }
  37. $response["success"] = 1;
  38.  
  39. // echoing JSON response
  40. echo json_encode($response);
  41.    
  42. ?>
Advertisement
Add Comment
Please, Sign In to add comment