/[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 52 by torben, Wed Jun 11 12:15:14 2008 UTC revision 193 by torben, Wed Dec 17 23:43:26 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    #include "Exceptions.h"
7    #include "Logger.h"
8    
9    #include "HttpClient.h"
10    
11  #include <vector>  #include <vector>
12  #include <sstream>  #include <sstream>
13    #include <stdexcept>
14    
15    
16  using namespace std;  using namespace std;
17    
# Line 58  vector<TrainInfo> GetTrainInfo(string st Line 64  vector<TrainInfo> GetTrainInfo(string st
64    
65          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;
66    
67          string raw_doc = Util::readUrl(url, "/tmp/sms_tog.tmp" );          //string raw_doc = Util::readUrl(url, "/tmp/sms_tog.tmp" );
68            
69            string raw_doc;
70            try
71            {
72                    raw_doc = HttpClient::GetString(url);
73            }
74            catch (httpexception& e)
75            {
76                    Logger::logMessage(e.what());
77            }
78    
79            if (raw_doc == "")
80            {
81                    throw std::runtime_error("Connection timeout");
82            }
83    
84          raw_doc = Util::str_replace(raw_doc, "\"", "'");          raw_doc = Util::str_replace(raw_doc, "\"", "'");
85    
86          string_nocase html = raw_doc.c_str();          string_nocase html = raw_doc.c_str();
87    
88          unsigned int pos =0; // = html.find("id='ankomsttabel'");          unsigned int pos =0;
89    
90            unsigned int ankomstpos = html.find("id='ankomsttabel'");
91    
92          while(1)          while(1)
93          {          {
# Line 73  vector<TrainInfo> GetTrainInfo(string st Line 97  vector<TrainInfo> GetTrainInfo(string st
97                  if (pos == string::npos)                  if (pos == string::npos)
98                          break;                          break;
99    
100                    if (pos > ankomstpos)
101                            break;
102    
103                  TrainInfo info;                  TrainInfo info;
104    
105                  int start = pos+16;                  int start = pos+16;

Legend:
Removed from v.52  
changed lines
  Added in v.193

  ViewVC Help
Powered by ViewVC 1.1.20