#include <iostream>
#include <fstream>
#include <string>
#include <boost/asio.hpp>
#include <boost/lexical_cast.hpp>
using namespace std;
using boost::lexical_cast;
using namespace boost::asio::ip;
int main()
{
ifstream file("cookie");
string cookie;
file >> cookie;
if (file.is_open() == false)
{
cout << "Keine Kekse keine Arme :/" << endl;
return 0;
}
cout << "Let's see..." << endl;
string tanga;
tanga = "GET / HTTP/1.0\r\n";
tanga += "Host: www.losefriends.de\r\n";
tanga += "Cookie: " + cookie + "\r\n";
tcp::iostream page( "www.losefriends.de", "http" );
page << tanga << "\r\n" << flush;
string response = lexical_cast<string>( page.rdbuf() );
size_t pos0 = response.find( "Kontoguthaben:" );
size_t pos1 = response.find( "Bonuslose:", pos0);
size_t pos2 = response.find( "Dein Tagesumsatz:", pos1);
size_t pos3 = response.find( "Platz " );
size_t pos4 = response.find( "mit", pos3 );
pos0 += 24;
pos1 += 20;
pos2 += 25;
pos3 += 24;
pos4 += 7; // der muss noch 3 Zeichen weiter springen
size_t pend0 = response.find( " ", pos0 );
size_t pend1 = response.find( " ", pos1 );
size_t pend2 = response.find( " ", pos2 );
size_t pend3 = response.find( "&", pos3 ); // der endet bei " " und nicht bei " "
size_t pend4 = response.find( " ", pos4 ); // dafuer endet der dann bei " "
string score0;
score0 = lexical_cast<string>( response.substr( pos0, pend0-pos0 ));
string score1;
score1 = lexical_cast<string>( response.substr( pos1, pend1-pos1 ));
string score2;
score2 = lexical_cast<string>( response.substr( pos2, pend2-pos2 ));
string score3;
score3 = lexical_cast<string>( response.substr( pos3, pend3-pos3 ));
string score4;
score4 = lexical_cast<string>( response.substr( pos4, pend4-pos4 ));
cout << "Kontoguthaben: \t\t" << score0 << endl;
cout << "Bonuslose: \t\t" << score1 << endl;
cout << "Dein Tagesumsatz: \t" << score2 << endl;
cout << "Dein Rang: \t\t" << score3 << endl; // der brauchte noch einen tab mehr damits passt =)
cout << "Punkte: \t\t" << score4 << endl; // der auch, muss ja schoen aussesehen
}