Jump to content

How to get Webpage contnet in a Variable?


anks

Recommended Posts

Folks,

 

Been 2 days, still trying to figure out how to get around this.

 

I need to extract the webpage content in a PHP variable.

 

http://affiliates.beso.com/product-search/content?publisherId=27085&categoryId=&keyword=furniture-entertainment-center&showDesc=imageDescriptionText&col=4&row=4&placementid=2&minMarkdown=0&w=140&h=160\

 

Till now, i have used CURL, fopen, file_get_contents() but all in vain. there is no Output written to the Variable ($prodlist).

 

Could some one help me with this requirement, Please?  :-\

 

 

 

 

 

Ok as you suggested, here is my CURL:

 

<?php





function curl_download($Url){

    // is cURL installed yet?
    if (!function_exists('curl_init')){
        die('Sorry cURL is not installed!');
    }

    // OK cool - then let's create a new cURL resource handle
    $ch = curl_init();

    // Now set some options (most are optional)

    // Set URL to download
    curl_setopt($ch, CURLOPT_URL, $Url);

    // Set a referer
    //curl_setopt($ch, CURLOPT_REFERER, "http://www.google.com/yay.htm");

    // User agent
    curl_setopt($ch, CURLOPT_USERAGENT, "MozillaXYZ/1.0");

    // Include header in result? (0 = yes, 1 = no)
    curl_setopt($ch, CURLOPT_HEADER, 0);

    // Should cURL return or print out the data? (true = return, false = print)
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);

    // Timeout in seconds
    curl_setopt($ch, CURLOPT_TIMEOUT, 10);

    // Download the given URL, and return output
    $output = curl_exec($ch);

    // Close the cURL resource, and free system resources
    curl_close($ch);

    return $output;
}

$url = "http://affiliates.beso.com/product-search/content?publisherId=57085&categoryId=&keyword=paintball%20mask&showDesc=imageDescriptionText&col=4&row=4&placementid=1&minMarkdown=0&w=140&h=160";

$szlcontent =  curl_download($url);

echo $szlcontent;
?>

 

 

 

Returns NOthing.

 

At the same time, This URL has Products still CURL not able to Dump in a Variable...  :-\

 

http://affiliates.beso.com/product-search/content?publisherId=57085&categoryId=&keyword=paintball%20mask&showDesc=imageDescriptionText&col=4&row=4&placementid=1&minMarkdown=0&w=140&h=160

 

Any Help Please?

Your curl script is working. The problem is that the url

http://affiliates.beso.com/product-search/content?publisherId=57085&categoryId=&keyword=paintball%20mask&showDesc=imageDescriptionText&col=4&row=4&placementid=1&minMarkdown=0&w=140&h=160

 

Is only returning this html code

<?xml version='1.0' encoding='UTF-8'?> 
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> 
<html xml:lang="en" lang="en"> 
    <head> 
        <link rel="stylesheet" type="text/css" href="http://img13.beso-images.com/s2static/us/pb/6706a675/local/css/common/product_gallery.css"/> 
        <script type="text/javascript" src="http://img13.beso-images.com/s2static/us/pb/6706a675/local/js/widget/content.js"> </script> 
        <script type="text/javascript" src="http://img13.beso-images.com/s2static/us/pb/6706a675/local/js/widget/util.js"> </script> 
    </head> 
    <body onload="BesoWidget.searchForProducts();" id="iframe-body"> 
        <form name="config"> 
            <input id="sho.publisherId" type="hidden" value="25225"> </input> 
            <input id="sho.apiKey" type="hidden" value="638b348a826889501ea9d18d8984ab44"> </input> 
            <input id="sho.serverTimeout" type="hidden" value="5000"> </input> 
            <input id="sho.serverUrl" type="hidden" value="http://catalog.bizrate.com"> </input> 
            <input id="sz.assetid" type="hidden" value="2795"> </input> 
        </form> 
    </body> 

</html>

The list of products appears to be being listed dynamically using JavaScript.

hey Anks, may I ask whose webpage that is? lol ... and what do you want to do after you store the page inside a variable?

I have similare problem and able to solved this this way

$file = file_get_contents ('path to webpage', true);

If that doesn't work, write the webpage content to file first, then open it and do the file get content, this will definitly work...

 

let me know  :D

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.