note 19497 modified in function.curl-exec by vincent

From: Date: Fri, 03 Oct 2003 11:41:07 +0000
Subject: note 19497 modified in function.curl-exec by vincent
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-57712@lists.php.net to get a copy of this message
fyi - if you are having problems getting a webpage to display in your webpage with curl_setopt(CURLOPT_RETURNTRANSFER, 1); due to version bugginess perhaps, you may can use output control functions like this to show a web page inside your webpage: <html><head><title>whatever</title></head> <body> <script language="php"> $ch = curl_init("http://www.cocoavillage.com/"); // use output buffering instead of returntransfer -itmaybebuggy ob_start(); curl_exec($ch); curl_close($ch); $retrievedhtml = ob_get_contents(); ob_end_clean(); // if you intend to print this page with meta tags, better clear out any expiration tag // $result = preg_replace('/(?s)<meta http-equiv="Expires"[^>]*>/i', '', $retrievedhtml); // for now I just want what is between the body tags so need // somehow cut the header footer $bodyandend = stristr($retrievedhtml,"<body"); // not needed- $positionstartbodystring = strlen($retrievedhtml)-strlen($bodyandend); $positionendstartbodytag = strpos($bodyandend,">") + 1; // got to change all to lowercase temporarily // because end body may be upperlowercasemix // to bad strirstr does not exist $temptofindposition=strtolower($bodyandend); $positionendendbodytag=strpos($temptofindposition,"</body"); //now to get the endbetween body tags $grabbedbody=substr($bodyandend, $positionendstartbodytag, $positionendendbodytag); //be sure to fix syntax broke by display on phpwebsite... like above line print("$grabbedbody"); </script> </body></html> tada --was-- fyi - if you are having problems getting a webpage to display in your webpage with curl_setopt(CURLOPT_RETURNTRANSFER, 1); due to version bugginess perhaps, you may can use output control functions like this to show a web page inside your webpage: <html><head><title>whatever</title></head> <body> <script language="php"> $ch = curl_init("http://www.cocoavillage.com/"); // use output buffering instead of returntransfer -itmaybebuggy curl_exec($ch); curl_close($ch); $retrievedhtml = ob_get_contents(); ob_end_clean(); // if you intend to print this page with meta tags, better clear out any expiration tag // $result = preg_replace('/(?s)<meta http-equiv="Expires"[^>]*>/i', '', $retrievedhtml); // for now I just want what is between the body tags so need // somehow cut the header footer $bodyandend = stristr($retrievedhtml,"<body"); // not needed- $positionstartbodystring = strlen($retrievedhtml)-strlen($bodyandend); $positionendstartbodytag = strpos($bodyandend,">") + 1; // got to change all to lowercase temporarily // because end body may be upperlowercasemix // to bad strirstr does not exist $temptofindposition=strtolower($bodyandend); $positionendendbodytag=strpos($temptofindposition,"</body"); //now to get the endbetween body tags $grabbedbody=substr($bodyandend, $positionendstartbodytag, $positionendendbodytag); //be sure to fix syntax broke by display on phpwebsite... like above line print("$grabbedbody"); </script> </body></html> tada http://www.php.net/manual/en/function.curl-exec.php

« previous php.notes (#57712) next »