Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- include('../simplehtmldom/simple_html_dom.php');
- function GetData($strLink)
- {
- // -----------------------------------------------------------------------------
- // Retrieve the DOM from a given URL
- $html = file_get_html($strLink);
- $i=0;
- $timeupdate = array();
- foreach($html->find('span[style="font-size:14px; color:#fff; "]') as $e) {
- $timeupdate[$i++] = $e->innertext;
- }
- $i=0;
- $product = array();
- foreach($html->find('td[class="number_kq"]') as $e) {
- $product[$i++] = $e->innertext;
- }
- $response["products"] = array();
- for ($i=0; $i < 5; $i++) {
- $kqmb["Time"]=$timeupdate[$i];
- $j=$i*8;
- $kqmb["DB"]=$product[$j++];
- $kqmb["G1"]=$product[$j++];
- $kqmb["G2"]=$product[$j++];
- $kqmb["G3"]=$product[$j++];
- $kqmb["G4"]=$product[$j++];
- $kqmb["G5"]=$product[$j++];
- $kqmb["G6"]=$product[$j++];
- $kqmb["G7"]=$product[$j++];
- array_push($response["products"], $kqmb);
- $ketqua = $kqmb["DB"] . "," . $kqmb["G1"] . "," . $kqmb["G2"] . "," . $kqmb["G3"] . "," . $kqmb["G4"] . "," . $kqmb["G5"] . "," . $kqmb["G6"] . "," . $kqmb["G7"];
- $thoigian = $kqmb["Time"];
- $thoigian = trim($thoigian);
- $tg = explode(" ", $thoigian);
- $thoigian = $tg[1];
- //echo $thoigian . " " . $ketqua . "<br/>";
- $conn=mysql_connect("localhost","root","admin") or die("can't connect this database");
- mysql_select_db("appkqxs",$conn);
- // mysql inserting a new row
- $result = mysql_query("INSERT INTO kqmienbac(ketqua, thoigian) VALUES('$ketqua', '$thoigian')");
- }
- }
- GetData("http://ketquaxoso.24h.com.vn/xo-so-mien-bac/");
- $k=1;
- for ($i=2; $i <= 503; $i++) {
- echo $k++ . "<br/>";
- $strLink = "http://ketquaxoso.24h.com.vn/xo-so-mien-bac/page" . $i;
- GetData($strLink);
- sleep(1);
- }
- ?>
Advertisement
Add Comment
Please, Sign In to add comment