1. Advertising
    y u no do it?

    Advertising (learn more)

    Advertise virtually anything here, with CPM banner ads, CPM email ads and CPC contextual links. You can target relevant areas of the site and show ads based on geographical location of the user if you wish.

    Starts at just $1 per CPM or $0.10 per CPC.

Buying PHP and CURL scraping expert needed

Discussion in 'Programming' started by Brewster, Jul 23, 2012.

  1. #1
    Hi

    I'm looking for some help to get image data from ubid.com auctions using php and curl. I have managed to scrape the url of an image - this looks like this:

    http://static.ubid.com/mgen/vximg/scale.ms?args=%221_10203259_0.jpg%22,275,275
    Code (markup):
    If I wrap an html img tag around this, the image displays ok. When I try to use getimagesize(), it returns an empty array as though the file does not exist.

    First person to help me solve this issue gets $10

    Thanks,
    Joe
     
    Brewster, Jul 23, 2012 IP
  2. cah.ndeso

    cah.ndeso Member

    Messages:
    32
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    36
    Digital Goods:
    2
    As Seller:
    100% - 26
    As Buyer:
    100% - 0
    #2
    have pm sent.
    thanks.
     
    cah.ndeso, Jul 23, 2012 IP
  3. ThomThom

    ThomThom Greenhorn

    Messages:
    21
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    11
    As Seller:
    100% - 0
    As Buyer:
    100% - 0
    #3
    Sent you a PM.
     
    ThomThom, Jul 23, 2012 IP
  4. SentoWeb

    SentoWeb Active Member

    Messages:
    189
    Likes Received:
    10
    Best Answers:
    0
    Trophy Points:
    80
    Digital Goods:
    3
    As Seller:
    100% - 2
    As Buyer:
    100% - 0
    #4
    getimagesize expects a valid file hosted on your own server, thus you will have to download the image before being able to get it's size.

    preg_match('#args=%(.*?)%#si', $image_url, $filename); // Get the filename (stored as $filename[1]);
    curl_setopt($ch, CURLOPT_URL, $image_url);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
    $data = curl_exec($ch);
    file_put_contents('temporary/'.$filename[1], $data); // Store the file

    print_r(getimagesize('temporary/'.$filename[1]));

    unlink('temporary/'.$filename[1]); // Delete the file

    ---------

    This should help you, please donate the $10 to a charity.

    PS: Make sure to create the temporary directory and chmod it to 777. There are alternative ways on how to do this however unless you're very experienced at cUrl this is the most suitable method for you.
     
    SentoWeb, Jul 23, 2012 IP
    KangBroke likes this.
  5. ThomThom

    ThomThom Greenhorn

    Messages:
    21
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    11
    As Seller:
    100% - 0
    As Buyer:
    100% - 0
    #5

    Wrong.

    "It can reference a local file or (configuration permitting) a remote file using one of the supported streams."
    http://php.net/manual/en/function.getimagesize.php

    If you have the http:// wrapper enabled, the following works:

    
    <?php print_r(getimagesize('http://static.ubid.com/mgen/vximg/scale.ms?args=%221_10203259_0.jpg%22,275,275')); ?>
    
    PHP:
     
    ThomThom, Jul 24, 2012 IP
  6. indiajobvacancy

    indiajobvacancy Banned

    Messages:
    341
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    0
    As Seller:
    100% - 0
    As Buyer:
    100% - 0
    #6
    Thanks ThomThom, and SentoWeb to make ThomThom share his knowledge.
     
    indiajobvacancy, Jul 24, 2012 IP
  7. Brewster

    Brewster Active Member

    Messages:
    489
    Likes Received:
    13
    Best Answers:
    0
    Trophy Points:
    60
    As Seller:
    100% - 0
    As Buyer:
    100% - 0
    #7
    This has now been sorted. The problem was that I needed to use trim on the variable that I was using to hold the image url - there must have been white space at one or both ends of the variable.

    Thanks to everyone that offered help.

    Joe
     
    Brewster, Jul 24, 2012 IP
  8. Wav3

    Wav3 Well-Known Member

    Messages:
    247
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    101
    As Seller:
    100% - 0
    As Buyer:
    100% - 0
    #8
    First time you must save the image on your hosting and then get it's resolution.
     
    Wav3, Jul 25, 2012 IP
  9. Brewster

    Brewster Active Member

    Messages:
    489
    Likes Received:
    13
    Best Answers:
    0
    Trophy Points:
    60
    As Seller:
    100% - 0
    As Buyer:
    100% - 0
    #9
    No, you are incorrect as already pointed out by several people in this thread. My issue was that there was whitespace in the url
     
    Brewster, Jul 25, 2012 IP