Beispiel #1
0
} else {
    $Html = download_page("{$Host}/bets.php?line_id[]={$Sport}", "GET", "{$Host}/center.php");
}
function extract_league($Html)
{
    $Html = replace_all($Html, '<table', '</table>', '', 'долгосрочные ставки');
    return extract_form_hash($Html);
}
$Form = copy_be(win1251_to_utf8($Html), '<form id="fbets"', '</form>');
if ($debug) {
    file_put_contents($Lines . "form.txt", $Form);
}
$PostHash = extract_league($Form);
$FormAction = extract_form_action($Form);
if ($debug) {
    file_put_contents($Lines . "league.txt", implode_hash("\r\n", $PostHash));
}
// Получаем перечень турниров
$PostHash['simple'] = 'on';
if ($debug) {
    $FileName = $Lines . "bets.html";
    if (!file_exists($FileName)) {
        $Html = download("{$Host}/{$FormAction}", "POST", "{$Host}/bets.php?line_id[]={$Sport}", $PostHash);
        file_put_contents($FileName, $Html);
    } else {
        $Html = file_get_contents($FileName);
    }
} else {
    $Html = download("{$Host}/{$FormAction}", "POST", "{$Host}/bets.php?line_id[]={$Sport}", $PostHash);
}
function extract_bet($Html)
Beispiel #2
0
function download_curl($Url, $Method = "GET", $Proxy = null, $Referer = "", $PostHash = null)
{
    $URI = parse_url($Url);
    $cookiehost = $URI['host'];
    try {
        $curl = curl_init();
        curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
        curl_setopt($curl, CURLOPT_HEADER, true);
        curl_setopt($curl, CURLOPT_URL, $Url);
        curl_setopt($curl, CURLOPT_USERAGENT, 'User-Agent=Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.0.6) Gecko/2009011913 Firefox/3.0.6 (.NET CLR 3.5.30729)');
        curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false);
        curl_setopt($curl, CURLOPT_FOLLOWLOCATION, true);
        if ($Referer) {
            curl_setopt($curl, CURLOPT_REFERER, $Referer);
        }
        curl_setopt($curl, CURLINFO_HEADER_OUT, true);
        if (file_exists("cookies/{$cookiehost}.txt")) {
            $cookie = str_replace("\r\n", '; ', urldecode(file_get_contents("cookies/{$cookiehost}.txt")));
            curl_setopt($curl, CURLOPT_COOKIE, $cookie);
        }
        if ($Proxy) {
            curl_setopt($curl, CURLOPT_PROXY, $Proxy);
        }
        if ($Method == "POST") {
            curl_setopt($curl, CURLOPT_POST, true);
            curl_setopt($curl, CURLOPT_POSTFIELDS, implode_hash("\r\n", $PostHash));
        }
        $data = curl_exec($curl);
        $curlError = curl_error($curl);
        if ($Proxy) {
            list($header, $data) = explode("\r\n\r\n", $data, 2);
        }
        while (substr($data, 0, 4) == 'HTTP') {
            list($header, $data) = explode("\r\n\r\n", $data, 2);
            update_cookies($Url, $header);
        }
        curl_close($curl);
    } catch (E_NOTICE $e) {
        echo "Notice raised: " . $e->getMessage();
    }
    return $data;
}