thieumao

Lấy kết quả xổ số miền bắc trả về client dạng JSON

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