--- smsdaemon/plugins/TrainInfo.cpp 2008/06/11 08:25:34 44 +++ smsdaemon/plugins/TrainInfo.cpp 2008/06/15 19:33:02 81 @@ -6,6 +6,8 @@ #include #include +#include + using namespace std; @@ -59,11 +61,19 @@ string url = string("http://www.bane.dk/visStation.asp?W=FJRN&S=") + stationcode + "&artikelId=4275&statnavn=" + stationname; string raw_doc = Util::readUrl(url, "/tmp/sms_tog.tmp" ); + + if (raw_doc == "") + { + throw std::runtime_error("Connection timeout"); + } + raw_doc = Util::str_replace(raw_doc, "\"", "'"); string_nocase html = raw_doc.c_str(); - unsigned int pos = html.find("id='ankomsttabel'"); + unsigned int pos =0; + + unsigned int ankomstpos = html.find("id='ankomsttabel'"); while(1) { @@ -73,6 +83,9 @@ if (pos == string::npos) break; + if (pos > ankomstpos) + break; + TrainInfo info; int start = pos+16;