189 |
|
|
190 |
ostringstream command; |
ostringstream command; |
191 |
command << "wget -O " << tempfile << " --tries=1 --timeout=15 -o /dev/null \"" << url << "\""; |
command << "wget -O " << tempfile << " --tries=1 --timeout=15 -o /dev/null \"" << url << "\""; |
192 |
int res = system( command.str().c_str() ); |
int res = my_system( command.str().c_str() ); |
193 |
|
|
194 |
|
if (res<0) |
195 |
|
{ |
196 |
|
throw( std::runtime_error("Error retrieving document")); |
197 |
|
} |
198 |
|
|
199 |
if (res>0) |
if (res>0) |
200 |
{ |
{ |
201 |
throw std::runtime_error("Command time out"); |
throw std::runtime_error("Command time out or document not found"); |
202 |
} |
} |
203 |
|
|
204 |
ifstream in( tempfile.c_str() ); |
ifstream in( tempfile.c_str() ); |
289 |
((now.tv_usec-then.tv_usec)/1000); |
((now.tv_usec-then.tv_usec)/1000); |
290 |
} |
} |
291 |
|
|
292 |
|
int my_system(const char* cmd) |
293 |
|
{ |
294 |
|
FILE* p; |
295 |
|
if ((p = popen(cmd,"w")) == NULL) |
296 |
|
return (-1); |
297 |
|
return (pclose(p)); |
298 |
|
} |
299 |
|
|
300 |
} |
} |
301 |
|
|
302 |
|
|