dilbertone Posted November 26, 2010 Share Posted November 26, 2010 Hi dear community i want to run a Curl to get the contents of a remote web page into a PHP variable <?php // // The PHP curl module supports the received page to be returned in a variable // if told. // $ch = curl_init(); curl_setopt($ch, CURLOPT_URL,"http://www.myurl.com/"); curl_setopt($ch, CURLOPT_RETURNTRANSFER,1); $result=curl_exec ($ch); curl_close ($ch); ?> I declare this variable:($ch) Well - can i work with this variable - eg. to parse this with a parser!? look forward to hear from you $result=curl_exec ($ch); gretings Quote Link to comment Share on other sites More sharing options...
dilbertone Posted November 26, 2010 Author Share Posted November 26, 2010 Hi dear friends, i want to run a Curl to get the contents of a remote web page into a PHP variable and btw: if i add this code - i will clean the stuff from header and bottom content..!? Does this work!? <?php // // The PHP curl module supports the received page to be returned in a variable // if told. // $ch = curl_init(); curl_setopt($ch, CURLOPT_URL,"http://www.myurl.com/"); curl_setopt($ch, CURLOPT_RETURNTRANSFER,1); $result=curl_exec ($ch); curl_close ($ch); ?> I declare this variable:($ch) Well - can i work with this variable - eg. to parse this with a parser!? look forward to hear from you $result=curl_exec ($ch); greetings yours meta if($ch) { // This will clean all the unneeded top and bottom content and return only the table and divs data $cleaned = string_between('onload="check();">', '</body>', $data); // From here it's easy, clean out any unneeded content such as images and divs // Setting the second parameter, allows us to specify which tags NOT to remove, ie. tables, divs, paragraphs etc. // If we don't want any html tags, simply leave it as strip_tags($cleaned); // This will remove ALL the html tags and return only the content between. return = stip_tags($cleaned, '<table><tr><td><div>'); } look forward to hear from you! Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.