Lista winnt@man.lodz.pl
[Lista archiwów] [Inne Listy]

Re: [WINNT] Strona z wynikami Lotto ?

To: winnt@man.lodz.pl
Subject: Re: [WINNT] Strona z wynikami Lotto ?
From: artiun <artiun@spam.wp.pl>
Date: Mon, 22 May 2017 23:17:40 +0200
W dniu 2017-05-22 o 17:48, EZ pisze:
Przepraszam, że piszę na tę grupę,
ale wszystkie inne, które mogłyby
mniej więcej pasować, są już martwe.

Kiedyś była taka strona z wynikami
Lotto, na ktorej można było wpisać
6 zwykle typowanych liczb w Lotto,
a w wyniku otrzymywało się przegląd
wielu losowań wstecz i odpowiedzi
co do ewentualnych trafień.
Potem ta strona została zlikwidowana.
Czy coś takiego gdzieś istnieje?
Jeśli tak, proszę o podanie adresu.

Pozdrawiam
EZ

Możesz się uśmiać :) Kiedyś ściągałem z http://www.lotto.pl/.
Patrzę na datę, a to 2006 rok :) Wtedy ściągałem wsio, wszystkie wyniki. Reszta to wydumane statystyki :)
I tak tego nie przeskoczysz, za mało danych przy 13 milionach kombinacji.
parsownie strony:



#include <iostream>
#include <string>

#include <curl/curl.h>
#include <curl/types.h>
#include <curl/easy.h>

#include "dl_curl.h"

using namespace std;

/*
 * DLhtml();
 */
void LottoHtml()
{
}

/*
 * ~DLhtml();
 */
void ~LottoHtml()
{
}

/*
 * LottoHtml::TagsCut
 */
void LottoHtml::TagsCut( const string & strIn,
                         string & strOut,
                         const string tagb,
                         const string tage )
{
   string::size_type loc;

   loc = strIn.find( tagb );

   if( loc != string::npos )
      strOut = strIn.substr( loc + tagb.length( ) );

   loc = strOut.find( tage );

   if( loc != string::npos )
      strOut = strOut.substr( 0, loc );
}

/*
 * LottoHtml::WriteMemoryCallback
 */

static int LottoHtml::WriteMemoryCallback( char * data,
                                           size_t size,
                                           size_t nmemb,
                                           std::string * writerData )
{
   if( writerData == NULL )
      return 0;

   writerData->append( data, size *nmemb );

   return size * nmemb;
}

/*
 * LottoHtml::GetLastLotto
 */

bool LottoHtml::GetLastLotto( vector<string> &vecStrLast )
{
   CURL       *curl;
   CURLcode   res;
   string     strLast;
   bool lOk = false;

   curl_global_init( CURL_GLOBAL_ALL );
   curl = curl_easy_init( );

   if( curl )
   {
      curl_easy_setopt( curl, CURLOPT_URL, "www.lotto.pl" );
      curl_easy_setopt( curl, CURLOPT_WRITEFUNCTION, WriteMemoryCallback );
      curl_easy_setopt( curl, CURLOPT_WRITEDATA, &strLast );
      curl_easy_setopt( curl, CURLOPT_NOPROGRESS, 1 );

      res = curl_easy_perform( curl );

      if( CURLE_OK == res )
      {
TagsCut( strHtml, vecStrLast[0], "<span class=\"data\" id=\"data_dl\">", "</span>" );
         TagsCut( strHtml, vecStrLast[1], "<div class=\"d1\">", "</div>" );
         TagsCut( strHtml, vecStrLast[2], "<div class=\"d2\">", "</div>" );
         TagsCut( strHtml, vecStrLast[3], "<div class=\"d3\">", "</div>" );
         TagsCut( strHtml, vecStrLast[4], "<div class=\"d4\">", "</div>" );
         TagsCut( strHtml, vecStrLast[5], "<div class=\"d5\">", "</div>" );
         TagsCut( strHtml, vecStrLast[6], "<div class=\"d6\">", "</div>" );

         lOk = true;
      }
      curl_easy_cleanup( curl );
   }

   return( lOk );
}

/*
 * LottoHtml::GetArchLotto
 */

bool LottoHtml::GetArchLotto( string &strArch )
{
   CURL     *curl;
   CURLcode res;
   int lOk = false;

   curl_global_init( CURL_GLOBAL_ALL );
   curl = curl_easy_init( );

   if( curl )
   {
curl_easy_setopt( curl, CURLOPT_URL, "serwis.lotto.pl:8080/archiwum/wyniki_wszystkie.php?id_gra=1" );
      curl_easy_setopt( curl, CURLOPT_WRITEFUNCTION, WriteMemoryCallback );
      curl_easy_setopt( curl, CURLOPT_WRITEDATA, &strArch );
      curl_easy_setopt( curl, CURLOPT_NOPROGRESS, 1 );

      res = curl_easy_perform( curl );

      if( CURLE_OK == res )
         lOk = true;

      curl_easy_cleanup( curl );
   }

   return( lOk );
}


--
Artur

<Pop. w Wątku] Aktualny Wątek [Nast. w Wątku>