Advertisement
Help Keep Boards Alive. Support us by going ad free today. See here: https://subscriptions.boards.ie/.
If we do not hit our goal we will be forced to close the site.

Current status: https://keepboardsalive.com/

Annual subs are best for most impact. If you are still undecided on going Ad Free - you can also donate using the Paypal Donate option. All contribution helps. Thank you.
https://www.boards.ie/group/1878-subscribers-forum

Private Group for paid up members of Boards.ie. Join the club.

Fetch another sites HTML via cURL?

  • 28-09-2008 08:52PM
    #1
    Closed Accounts Posts: 94 ✭✭


    Hey,

    I'm trying to get my head around cURL.

    Basically, ATM, I'm just trying to grab the pages HTML.

    Can anyone give me a tip with starting this off?

    Thanks!


Comments

  • Closed Accounts Posts: 94 ✭✭gnomer


    Disregard this topic, I have solved it myself.

    file_get_contents($url);


  • Closed Accounts Posts: 7,144 ✭✭✭DonkeyStyle \o/


    Here's a good starting point on making sure curl is set up and working (read the comments)... http://ie.php.net/curl

    The most basic way to get something happening is this...
    [php]
    $url = "http://example.com";
    $handle = curl_init($url); //initialize
    curl_setopt($handle, CURLOPT_RETURNTRANSFER, true); //makes curl_exec() return the contents of the url instead of just true or false (default)
    $contents = curl_exec($handle); //make curl go
    curl_close($handle); //clean up
    [/php]


Advertisement