Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- //db
- $servername = "localhost";
- $username = "root";
- $password = "root";
- $dbname = "celebheight";
- // Create connection
- $conn = new mysqli($servername, $username, $password, $dbname);
- // Check connection
- if ($conn->connect_error) {
- die("Connection failed: " . $conn->connect_error);
- }
- // unicode
- $conn->set_charset("utf8");
- $sql_key = 'SELECT id, name FROM links where run = 0 limit 1';
- $st = $conn->prepare($sql_key);
- $st->execute();
- $st->bind_result($_id, $_name);
- while ($st->fetch()){
- }
- $stud = $conn->prepare('UPDATE `links` SET `run` = 1 WHERE `links`.`id` = ?;');
- $stud->bind_param('i',$_id);
- $stud->execute();
- include('../simple_html_dom.php');
- header('Content-Type: text/html; charset=utf-8');
- $key = 'who is '.$_name;
- $key = str_replace(' ','-',$key);
- $page = 'https://www.google.com.vn/search?q='.$key.'&oq='.$key.'&hl=en';
- $html = file_get_html($page);
- $name_ob = $html->find('div[class=_B5d]',0);
- $decription_ob = $html->find('div[class=_tXc] span',0);
- $height_ob = $html->find('span[class="_tA"]',1);
- $also_search_ob = $html->find('div[class=_rvh]',1)->find('div[class=_wSe] a[class="fl"]');
- $name = str_replace('‑',' ',$name_ob->innertext);
- $name = str_replace('-',' ',$name);
- $decription = str_replace('Wikipedia','',$decription_ob->plaintext);
- $height = iconv("ISO-8859-1", "UTF-8", $height_ob->innertext);
- $sql = 'INSERT INTO links (name,run) VALUES (?,1)';
- $stmt = $conn->prepare($sql);
- $stmt->bind_param('s',$name);
- $stmt->execute();
- $stmt->close();
- foreach ($also_search_ob as $item){
- if(!strpos($item->innertext, '...')){
- $name = str_replace('‑',' ',$item->innertext);
- $name = str_replace('-',' ',$name);
- $sql = 'INSERT INTO links (name) VALUES (?)';
- $stmt = $conn->prepare($sql);
- $stmt->bind_param('s',$name);
- $stmt->execute();
- $stmt->close();
- }
- }
- $conn->close();
- echo 'done';
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement