/[projects]/smsdaemon/plugins/TrainInfo.cpp
ViewVC logotype

Diff of /smsdaemon/plugins/TrainInfo.cpp

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 44 by torben, Wed Jun 11 08:25:34 2008 UTC revision 158 by torben, Mon Dec 8 21:49:49 2008 UTC
# Line 2  Line 2 
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    
# Line 59  vector<TrainInfo> GetTrainInfo(string st Line 61  vector<TrainInfo> GetTrainInfo(string st
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 = html.find("id='ankomsttabel'");          unsigned int pos =0;
75    
76            unsigned int ankomstpos = html.find("id='ankomsttabel'");
77    
78          while(1)          while(1)
79          {          {
# Line 73  vector<TrainInfo> GetTrainInfo(string st Line 83  vector<TrainInfo> GetTrainInfo(string st
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;

Legend:
Removed from v.44  
changed lines
  Added in v.158

  ViewVC Help
Powered by ViewVC 1.1.20