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 Link to comment https://forums.phpfreaks.com/topic/219907-curl-to-get-the-contents-of-a-remote-web-page-into-a-php-variable/ 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! Link to comment https://forums.phpfreaks.com/topic/219907-curl-to-get-the-contents-of-a-remote-web-page-into-a-php-variable/#findComment-1139974 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.