function get_news_page($page = 1) { $link = "https://alpari-uk.tradingcentral.com/index.asp?p=devises&page_watch=" . $page; $cookie2 = "alpari2.txt"; if (file_exists(realpath($cookie2)) == false) { alpari_tools(); get_trading_central(); get_news_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'; date_default_timezone_set('Europe/London'); $page = 1; write_stamp(); init_db(); do { get_news_page($page); $continue = get_news_section(); $page += 1; } while ($continue == true);