2 |
#include "TrainInfo.h" |
#include "TrainInfo.h" |
3 |
|
|
4 |
#include "string_nocase.h" |
#include "string_nocase.h" |
5 |
#include "util.h" |
#include "Util.h" |
6 |
|
|
7 |
#include <vector> |
#include <vector> |
8 |
#include <sstream> |
#include <sstream> |
9 |
|
#include <stdexcept> |
10 |
|
|
11 |
|
|
12 |
using namespace std; |
using namespace std; |
13 |
|
|
61 |
string url = string("http://www.bane.dk/visStation.asp?W=FJRN&S=") + stationcode + "&artikelId=4275&statnavn=" + stationname; |
string url = string("http://www.bane.dk/visStation.asp?W=FJRN&S=") + stationcode + "&artikelId=4275&statnavn=" + stationname; |
62 |
|
|
63 |
string raw_doc = Util::readUrl(url, "/tmp/sms_tog.tmp" ); |
string raw_doc = Util::readUrl(url, "/tmp/sms_tog.tmp" ); |
64 |
|
|
65 |
|
if (raw_doc == "") |
66 |
|
{ |
67 |
|
throw std::runtime_error("Connection timeout"); |
68 |
|
} |
69 |
|
|
70 |
raw_doc = Util::str_replace(raw_doc, "\"", "'"); |
raw_doc = Util::str_replace(raw_doc, "\"", "'"); |
71 |
|
|
72 |
string_nocase html = raw_doc.c_str(); |
string_nocase html = raw_doc.c_str(); |
73 |
|
|
74 |
unsigned int pos =0; // = html.find("id='ankomsttabel'"); |
unsigned int pos =0; |
75 |
|
|
76 |
|
unsigned int ankomstpos = html.find("id='ankomsttabel'"); |
77 |
|
|
78 |
while(1) |
while(1) |
79 |
{ |
{ |
83 |
if (pos == string::npos) |
if (pos == string::npos) |
84 |
break; |
break; |
85 |
|
|
86 |
|
if (pos > ankomstpos) |
87 |
|
break; |
88 |
|
|
89 |
TrainInfo info; |
TrainInfo info; |
90 |
|
|
91 |
int start = pos+16; |
int start = pos+16; |