#1
  1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Dec 2012
    Posts
    3
    Rep Power
    0

    How To Grab Content Of Another Site Using Php Culr


    Hi Everybody!
    I'm new to php programming and have no clue on doing this. I need to create a script to connect to another webshop and get all products from all categories and then save this informations to a database. I have a little script but i dont't know how to continuous.

    <?php function get_file($url){ $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, $url); curl_setopt($ch, CURLOPT_HEADER, false); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); curl_setopt($ch, CURLOPT_HTTPPROXYTUNNEL, true); curl_setopt($ch, CURLOPT_TIMEOUT_MS, 44000); $html = curl_exec($ch); curl_close($ch); return $html; } function getPage($html){ $page = 1; if ( preg_match("/<ol><span class=\"pppt\">([0-9]+) products found<\/span>/", $html, $rez) ) { $page = ceil($rez[1] / 100); } elseif ( preg_match("/<ol><span class=\"pppt\">Viewing all ([0-9]+) products<\/span>/", $html, $rez) ) { $page = ceil($rez[1] / 100); } return $page; } $url = "website-url/produs-"; echo get_file($url); function getColcode($html){ if ( preg_match_all('`website-url/images/products/([0-9]{8})_.*.jpg`Usi', $html, $rez) ) { return $rez[1]; } return false; } ?>
  2. #2
  3. --
    Devshed Expert (3500 - 3999 posts)

    Join Date
    Jul 2012
    Posts
    3,957
    Rep Power
    1046
    Hi,

    well, what are we supposed to do with that code snippet? We don't know your "other site".
  4. #3
  5. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Dec 2012
    Location
    Florida
    Posts
    6
    Rep Power
    0
    did you ask the other site if they had a xml file you could reference instead of scraping their site?

IMN logo majestic logo threadwatch logo seochat tools logo