From: Jens K. <jk...@we...> - 2016-01-03 10:50:31
|
Hello, I found some code on a website (dont remember): What I want, is, to check for the tag <script src ...> TIA int test_html(request_rec *req, char* file) { std::string url = "http://127.0.0.1/"; curlpp::Easy request; // Specify the URL request.setOpt(curlpp::options::Url(url)); // Specify some headers std::list<std::string> headers; headers.push_back(HEADER_ACCEPT); headers.push_back(HEADER_USER_AGENT); request.setOpt(new curlpp::options::HttpHeader(headers)); request.setOpt(new curlpp::options::FollowLocation(true)); // Configure curlpp to use stream std::ostringstream responseStream; curlpp::options::WriteStream streamWriter(&responseStream); request.setOpt(streamWriter); // Collect response request.perform(); std::string re = responseStream.str(); // Parse HTML and create a DOM tree xmlDoc* doc = htmlReadDoc((xmlChar*)re.c_str(), NULL, NULL, HTML_PARSE_RECOVER | HTML_PARSE_NOERROR | HTML_PARSE_NOWARNING); // Encapsulate raw libxml document in a libxml++ wrapper xmlNode* r = xmlDocGetRootElement(doc); xmlpp::Element* root = new xmlpp::Element(r); std::string xpath = "//html/head/title/text()"; auto elements = root->find(xpath); //std::string ads = "//html/head/" // the line below is the crash point std::string dstr = dynamic_cast<xmlpp::ContentNode*>(elements[0])->get_content(); ap_rprintf(req,dstr.c_str()); xmlFreeDoc(doc); return OK; } -- . ."| /| / | _.----._ . |/ |.-" ". /| / \/ |__ | _.-"""/ / | _.-" /."| / ".__.-" " | \ | | | /_ _.._ | ___ / ." ""-.-" ". |/.-.\/ | 0 | 0 | / | \ /\_ _/ "_/ "._ _/ "---" | /""" | \__.-- |_ ) . | ". / _.-"\ | ". / _.-" | ". (_ _.-| | |"-._. " "--. .J _.-' /\ _.-" | _.-' / \__..--" _.-' / | _.-' /| /\| _.-' / |/ _.-' /|_.-' _.-' |