function get_symbol_page($link, $page = 1) { $cookie2 = "alpari2.txt"; $link .= '&page_watch=' . $page; if (file_exists(realpath($cookie2)) == false) { alpari_tools(); get_trading_central(); get_symbol_page($link, $page); return; } $curl = curl_init(); curl_setopt($curl, CURLOPT_URL, $link); curl_setopt($curl, CURLOPT_VERBOSE, true); curl_setopt($curl, CURLOPT_RETURNTRANSFER, true); curl_setopt($curl, CURLOPT_USERAGENT, 'Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/30.0.1599.101 Safari/537.36'); curl_setopt($curl, CURLOPT_COOKIEFILE, realpath($cookie2)); $return = curl_exec($curl); $status = curl_getinfo($curl, CURLINFO_HTTP_CODE); curl_close($curl); if ($status == 302 || $status == 301) { unlink('alpari2.txt'); get_news_page(); return; } $fd = fopen('tmpResult.html', 'w'); fwrite($fd, $return); fclose($fd); }
<?php require_once 'loginData.php'; require_once 'curl_functions.php'; require_once 'db_functions.php'; require_once 'parsing.php'; require_once 'tools.php'; require_once 'news.php'; init_db(); $time = time(); $sObject = find_news_by_symbol($argv[1], $time); $first_link = htmlspecialchars_decode($sObject->link); $page = 1; do { get_symbol_page($first_link, $page); $continue = get_news_section(true); $page += 1; } while ($continue);