thieumao

Lấy tất cả kết quả Xổ Số Miền Bắc - bản chuẩn

Dec 3rd, 2013
243
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.68 KB | None | 0 0
  1. <?php
  2. include('../simplehtmldom/simple_html_dom.php');
  3. function GetData($strLink)
  4. {
  5.  
  6. // -----------------------------------------------------------------------------
  7.  
  8. // Retrieve the DOM from a given URL
  9. $html = file_get_html($strLink);
  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["products"] = array();
  24. for ($i=0; $i < 5; $i++) {
  25. $kqmb["Time"]=$timeupdate[$i];
  26. $j=$i*8;
  27.  
  28. $kqmb["DB"]=$product[$j++];
  29. $kqmb["G1"]=$product[$j++];
  30. $kqmb["G2"]=$product[$j++];
  31. $kqmb["G3"]=$product[$j++];
  32. $kqmb["G4"]=$product[$j++];
  33. $kqmb["G5"]=$product[$j++];
  34. $kqmb["G6"]=$product[$j++];
  35. $kqmb["G7"]=$product[$j++];
  36.  
  37. array_push($response["products"], $kqmb);
  38.  
  39. $ketqua = $kqmb["DB"] . "," . $kqmb["G1"] . "," . $kqmb["G2"] . "," . $kqmb["G3"] . "," . $kqmb["G4"] . "," . $kqmb["G5"]  . "," . $kqmb["G6"] . "," . $kqmb["G7"];
  40. $thoigian = $kqmb["Time"];
  41.  
  42. $thoigian = trim($thoigian);
  43. $tg = explode(" ", $thoigian);
  44. $thoigian = $tg[1];
  45.  
  46. //echo  $thoigian . "   " . $ketqua . "<br/>";
  47.  
  48.  
  49. $conn=mysql_connect("localhost","root","admin") or die("can't connect this database");
  50. mysql_select_db("appkqxs",$conn);
  51. // mysql inserting a new row
  52. $result = mysql_query("INSERT INTO kqmienbac(ketqua, thoigian) VALUES('$ketqua', '$thoigian')");
  53. }
  54. }
  55. GetData("http://ketquaxoso.24h.com.vn/xo-so-mien-bac/");
  56. $k=1;
  57. for ($i=2; $i <= 503; $i++) {
  58.     echo $k++ . "<br/>";
  59.     $strLink = "http://ketquaxoso.24h.com.vn/xo-so-mien-bac/page" . $i;
  60.     GetData($strLink);
  61.     sleep(1);
  62. }
  63. ?>
Advertisement
Add Comment
Please, Sign In to add comment