Answer the question
In order to leave comments, you need to log in
Is the curl code written correctly in the parsing loop?
Is the curl code written correctly in the parsing loop? initialization $cn = curl_init(); put in a loop?
if($act == 'go'){
$sql = $db->query("SELECT `game_id`, `game_prlink1` FROM $db_games WHERE game_prstatus<2 AND game_prlink1 IS NOT NULL AND game_prlink1 <> ''");
$ar_link = $sql->fetchAll(); //берем id и ссылки в массив
//$par_ok = print_r($ar_link);
$referer = 'http://www.google.com';
// 1. инициализация
$cn = curl_init();
// 2. устанавливаем опции включая урл в цикле
foreach ($ar_link as $row){
curl_setopt($cn, CURLOPT_URL, $row["game_prlink1"]);
curl_setopt($cn, CURLOPT_HEADER, 0);
curl_setopt($cn, CURLOPT_USERAGENT, "Mozilla/5.0 (Windows NT 6.1; WOW64; ry:38.0) Gecko/20100101 Firefox/38.0");
curl_setopt($cn, CURLOPT_REFERER, $referer);
curl_setopt($cn, CURLOPT_RETURNTRANSFER, true);
// 3. выполнение запроса и получение ответа
$data = curl_exec($cn);
//4. чистим html
$res2 = cot_keybox_parse($data, '<div class="bottom_line clearfix">', '<sup>');
$trimmed = trim($res2);
//5. запись в базу
$db->update($db_games, array('game_prstatus' => '1', 'game_prprice1' => $trimmed), "game_id = ".$row['game_id']."");
}
// 6. закрываем
curl_close($cn);
}
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question