//соеденяемся с базой
include "/functions.php";
$db = connectdb();
$i = 40745509;
while ($i <= 40745909) {
$url = 'https://znanija.com/task/'.$i;
// Создаём новый сеанс:
$curl = curl_init();
curl_setopt($curl, CURLOPT_URL, $url);
curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, 0);
curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, 0);
$headers = [];
$headers[] = 'Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.9';
$headers[] = 'Accept-Encoding: identity';
$headers[] = 'Accept-Language: ru-RU,ru;q=0.9,en-US;q=0.8,en;q=0.7';
$headers[] = 'Cache-Control: no-cache';
$headers[] = 'Connection: keep-alive';
$headers[] = 'Host: '.parse_url($url)['host'];
$headers[] = 'Pragma: no-cache';
$headers[] = 'Sec-Fetch-Dest: document';
$headers[] = 'Sec-Fetch-Mode: navigate';
$headers[] = 'Sec-Fetch-Site: none';
$headers[] = 'Sec-Fetch-User: ?1';
$headers[] = 'Upgrade-Insecure-Requests: 1';
$headers[] = 'User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/86.0.4240.193 Safari/537.36';
curl_setopt($curl, CURLOPT_HTTPHEADER, $headers);
curl_setopt($curl, CURLOPT_FOLLOWLOCATION, 1);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
$result = curl_exec($curl);
curl_close($curl);
preg_match('/<h1 data-test="question-box-text">(.*?)<\/h1>/si', $result, $matches);
preg_match('/<div class="brn-qpage-next-answer-box-content__section">(.*?)<\/div>/si', $result, $patches);
if (strlen($matches[1]) > 32 && strlen($patches[1]) > 104) {
$db->query("INSERT INTO `vii_blogs` (title,full_text) VALUES ('$matches[1]','$patches[1]')");
}
$i++;
$s = $i / 3;
if (is_integer($s)) {sleep(3);}
}