Advertisement
Guest User

phpquery10

a guest
Feb 7th, 2017
119
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.93 KB | None | 0 0
  1. require 'phpQuery.php';
  2.  
  3. $url = curl_init();
  4. curl_setopt($url, CURLOPT_URL, "http://33tura.ru/flagi");
  5. curl_setopt($url, CURLOPT_RETURNTRANSFER, 1);
  6. curl_setopt($url, CURLOPT_FOLLOWLOCATION, 1);
  7. $str = curl_exec($url);
  8. $pq = phpQuery::newDocument($str);
  9. $table = $pq->find("table");
  10.  
  11. $host = 'localhost';
  12. $user = 'root';
  13. $password = '';
  14. $db_name = 'phpquery';
  15. $connect = mysqli_connect($host, $user, $password, $db_name) or die(mysqli_error($link));
  16.  
  17. foreach ($table as $items){
  18. $items = pq($items);
  19. $img = $items->find('td img')->attr('src');
  20. $flag = 'http://33tura.ru/'.$img;
  21. $file = file_get_contents($flag);
  22. file_put_contents('../img/', $file);
  23.  
  24. $naname = $items->find('td a');
  25.  
  26. $query = "INSERT INTO page (id, title) VALUES (null, '".$name."')";
  27. $result = mysqli_query($connect, $query);
  28.  
  29. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement