Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- $url = curl_init();
- curl_setopt($url, CURLOPT_URL, "http://rybalku.ru/");
- curl_setopt($url, CURLOPT_RETURNTRANSFER, 1);
- curl_setopt($url, CURLOPT_FOLLOWLOCATION, 1);
- $str = curl_exec($url);
- preg_match_all('/<img src="http:\/\/rybalku\.ru\/prognoz\/clipart\/fish\/([^"]+)".+"ловля.+">([^<]+)<br/siU', $str, $fishes);
- $host = 'localhost';
- $user = 'root';
- $password = '';
- $db_name = 'phpquery';
- $connect = mysqli_connect($host, $user, $password, $db_name) or die(mysqli_error($link));
- foreach($fishes[2] as $i => $fishName){
- $fishImg = 'http://rybalku.ru/prognoz/clipart/fish/' . $fishes[1][$i];
- $file = file_get_contents($fishImg);
- file_put_contents('путь_к_папке/img/' . $fishes[1][$i], $file);
- // Прочитай это http://phpfaq.ru/newbie/paths и установи правильный путь к папке img/
- $result = mysqli_query($connect, 'INSERT INTO `page` (`title`) VALUES ("' . $fishName . '")');
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement