At work, I have a device in another part of the building, which hosts a web page: http://10.1.1.165/
which I need to parse.
I am attempting to use curlpp to retrieve the page and then libxml2 to parse the html.
Currently I have:
curlpp::Easy request;
request.setOpt(curlpp::options::Url(std::string("http://10.1.1.165/")));
std::list<std::string> headers;
headers.push_back(HEADER_ACCEPT);
headers.push_back(HEADER_USER_AGENT);
std::ostringstream responseStream;
curlpp::options::WriteStream streamWriter(&responseStream);
request.setOpt(streamWriter);
request.perform();
std::string re = responseStream.str();
htmlDoc = htmlReadDoc((xmlChar*)re.c_str(), NULL, NULL, HTML_PARSE_RECOVER | HTML_PARSE_NOERROR | HTML_PARSE_NOWARNING);
The code breaks on the line request.peform();
The output:
terminate called after throwing an instance of 'curlpp::LibcurlRuntimeError'
what(): No URL set!
I am very confused as I am following pretty identical instructions from the curlpp example code and an example provided here: https://blog.laplante.io/2014/11/parsing-html-c-revisited/
Am I forgetting to set some settings or incorrectly passing the url?