Advertisement
Guest User

phpquery12

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