working with cURL

Discussion in 'PHP' started by biobrain, May 23, 2008.

  1. #1
    I want to display some of contents from my one website to an other one live.

    I am planing using cURL for this job.

    Here is my code for this task

    Now by doing this I am able to get the whole contents of fileone.php on my second site

    I do not want to show the whole page just want to show the contents between the <table></table> tags from my fileone.php on my first site.

    Can you please guide me how I can make this selection of specific contents between the <table></table> and print them on my 2nd website
     
    biobrain, May 23, 2008 IP
  2. vtida.com

    vtida.com Peon

    Messages:
    12
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #2
    pls let me know, website that you need user Curl to extract content. i will help you
     
    vtida.com, May 23, 2008 IP
  3. biobrain

    biobrain Peon

    Messages:
    106
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #3
    I have just sent you the PM
     
    biobrain, May 23, 2008 IP
  4. vtida.com

    vtida.com Peon

    Messages:
    12
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #4
    pls check mail
     
    vtida.com, May 23, 2008 IP
  5. biobrain

    biobrain Peon

    Messages:
    106
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #5
    Thanks dear, It is almost done. you did a great job for me.
     
    biobrain, May 23, 2008 IP
  6. kasapa

    kasapa Peon

    Messages:
    86
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    0
    #6
    can you show the source code?
     
    kasapa, May 23, 2008 IP
  7. biobrain

    biobrain Peon

    Messages:
    106
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #7
    <?php
    echo "<center><h3>ForexPK Live Forex Currency Rates in Pakistan</h3> </center>";

    // create a new curl resource
    $ch = curl_init();

    // set URL and other appropriate options
    curl_setopt($ch, CURLOPT_URL, "http://My-URL.com");
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);

    // grab URL, and return output
    $output = curl_exec($ch);

    // close curl resource, and free up system resources
    curl_close($ch);

    // Replace '

    preg_match("/<td class=\"efef\">(.*?)<table.*?cellpadding=\"0\" id=\"table1\">/is",$output,$t);

    $output=str_replace('<td class="efef">','',$t[0]);
    $output=str_replace('<table border="0" cellspacing="0" width="80%" cellpadding="0" id="table1">','',$output);
    $tomorrow = date("Y/m/d");
    $output = str_replace( "buy", "$tomorrow", $output);
    echo $output;

    ?>
     
    biobrain, May 23, 2008 IP