SitePoint Sponsor

User Tag List

Results 1 to 6 of 6
  1. #1
    SitePoint Member
    Join Date
    Apr 2004
    Location
    nyc
    Posts
    2
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    PHP screen scrape for prices on XBOX products

    MY SCRIPT: Here is the PHP code I created for my more.php pages to dynamically scrape xbox product prices from GameStop.com:

    //<--start Paul's PHP Gamestop Scrape function-->//

    $symbol=''. $v[ProductName] .'';
    echo "COMPARE PRICES on $symbol <br /><br />";
    $varlength = strlen($symbol);

    $limit = 16;

    if ($varlength > $limit) {

    $symbol = substr($symbol,0,$limit) . "";}

    $theurl='http://www.gamestop.com/search.asp?sortby=price&searchtype=quicksearch&searchcount=12&keyword='.urlencode($symbol).'&platform=26';

    echo "Gamestop.com: ";

    if (!($fp = fopen($theurl, 'r')))
    {
    echo 'Could not open URL';
    exit;
    }
    $contents .= fread($fp, 1000000);

    fclose($fp);

    $pattern = "(\\$[0-9 ]+\\.[0-9]+)";
    if (eregi($pattern, $contents, $quote))
    {
    echo $quote[1];

    } else
    {
    echo 'No price available';
    };

    echo ''
    ." <a href=\"$theurl\"> more info</a> or <a href=\"$theurl\"> buy it now!</a><br /><br /><br />";

    //<--end Paul's PHP Gamestop Scrape function-->//

    MY PROBLEM: when the above scipt is executed, the incorrect data is displayed in my more.php pages....it returns $10.00 for everything...not sure why this is or if my script was even written correctly.

    EXAMPLE OF PROBLEM: http://www.xboxstore.com/more.php?i...1G&cat=3&pcat=0 Scroll down the page till you get right above the ebay auctions. Look for the words "COMPARE PRICES on HALO Gamestop.com: $10.00 more info or buy it now!" in small white letters. Notice that if you click "buy it now" it takes you to the correct page on GameSpot but fails to scrape the correct pricing.

    WHAT I AM TRYING TO DO: I would like my script to scrape the small image,the title of the product,the new or pre-owned price, and the corresponding buy link to purchase the product..for the first full page of product results. In this case, the first 9 matches for the XBOX game "Halo" desending from LOWEST PRICE to HIGHEST PRICE.

    ANY HELP WOULD BE GREATLY APPRECIATED AS IT HAS COST ME MANY FRUSTRATING HOURS OF NON PRODUCTIVE WORK..TRYING TO FIGURE IT ALL OUT. THANK YOU AND GODBLESS, paulie FROM NEW YORK CITY (xboxstore.com) email: paul@xboxstore.com aim:nylastyles

  2. #2
    ********* Wizard silver trophy Cam's Avatar
    Join Date
    Aug 2002
    Location
    Burpengary, Australia
    Posts
    4,495
    Mentioned
    0 Post(s)
    Tagged
    1 Thread(s)
    Please don't post your question in more than one forum. I'm going to get an Advisor to delete this thread.

  3. #3
    SitePoint Wizard
    Join Date
    Oct 2001
    Location
    Tucson, Arizona
    Posts
    1,858
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Is this even a) advanced PHP or b) legal/ethical?

  4. #4
    Non-Member
    Join Date
    Jan 2004
    Location
    Planet Earth
    Posts
    1,764
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    This is not an advanced topic of discussion. I wish people would learn to use this forums properly, as it only bloats the real topics to discuss

  5. #5
    SitePoint Guru dagfinn's Avatar
    Join Date
    Jan 2004
    Location
    Oslo, Norway
    Posts
    894
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by xboxstore.com
    ANY HELP WOULD BE GREATLY APPRECIATED AS IT HAS COST ME MANY FRUSTRATING HOURS OF NON PRODUCTIVE WORK..TRYING TO FIGURE IT ALL OUT.
    Here's a pointer: If you've spent hours trying to find out what's wrong and you still have no idea where in the script the problem is, then you first need to learn how to debug a script. And if you have any questions about that, this is not the forum to ask.
    Dagfinn Reiersøl
    PHP in Action / Blog / Twitter
    "Making the impossible possible, the possible easy,
    and the easy elegant"
    -- Moshe Feldenkrais

  6. #6
    Non-Member
    Join Date
    Jan 2004
    Location
    Planet Earth
    Posts
    1,764
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Way to go Dagfinn


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •