Advertisement
Guest User

Untitled

a guest
Feb 6th, 2017
104
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.99 KB | None | 0 0
  1. $url = curl_init();
  2. curl_setopt($url, CURLOPT_URL, "http://rybalku.ru/");
  3. curl_setopt($url, CURLOPT_RETURNTRANSFER, 1);
  4. curl_setopt($url, CURLOPT_FOLLOWLOCATION, 1);
  5. $str = curl_exec($url);
  6. preg_match_all('/<img src="http:\/\/rybalku\.ru\/prognoz\/clipart\/fish\/([^"]+)".+"ловля.+">([^<]+)<br/siU', $str, $fishes);
  7.  
  8. $host = 'localhost';
  9. $user = 'root';
  10. $password = '';
  11. $db_name = 'phpquery';
  12. $connect = mysqli_connect($host, $user, $password, $db_name) or die(mysqli_error($link));
  13.  
  14. foreach($fishes[2] as $i => $fishName){
  15. $fishImg = 'http://rybalku.ru/prognoz/clipart/fish/' . $fishes[1][$i];
  16. $file = file_get_contents($fishImg);
  17. file_put_contents('путь_к_папке/img/' . $fishes[1][$i], $file);
  18. // Прочитай это http://phpfaq.ru/newbie/paths и установи правильный путь к папке img/
  19.  
  20. $result = mysqli_query($connect, 'INSERT INTO `page` (`title`) VALUES ("' . $fishName . '")');
  21.  
  22. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement