Thread: Scraping HTML

Page 2 of 2 First 12
  • Jump to page:
    #16
  1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Feb 2008
    Posts
    22
    Rep Power
    0
    Originally Posted by ManiacDan
    Give an actual example of what you want, we can't continue to help you maybe spider a potential div which may be on a webserver somewhere.
    Ok sure,
    I would like to scrape the price ($399) of this item:
    http://www.samedaymusic.com/product--SEAS6

    Any idea how to do this?

    thanks
  2. #17
  3. No Profile Picture
    Contributing User
    Devshed Expert (3500 - 3999 posts)

    Join Date
    Jul 2003
    Posts
    3,617
    Rep Power
    595
    DOM is the way but without setting validate to true. However, be sure to check the TOS for any web site you intend to scrape.
    There are 10 kinds of people in the world. Those that understand binary and those that don't.
  4. #18
  5. Sarcky
    Devshed Supreme Being (6500+ posts)

    Join Date
    Oct 2006
    Location
    Pennsylvania, USA
    Posts
    10,908
    Rep Power
    6352
    regex will also work if all you need is a single field:


    Code:
    php > preg_match('/itemprop="price" content="([^"]+)"/', file_get_contents('http://www.samedaymusic.com/product--SEAS6'), $f);
    php > echo $f[1];
    399.99
    HEY! YOU! Read the New User Guide and Forum Rules

    "They that can give up essential liberty to obtain a little temporary safety deserve neither liberty nor safety." -Benjamin Franklin

    "The greatest tragedy of this changing society is that people who never knew what it was like before will simply assume that this is the way things are supposed to be." -2600 Magazine, Fall 2002

    Think we're being rude? Maybe you asked a bad question or you're a Help Vampire. Trying to argue intelligently? Please read this.
Page 2 of 2 First 12
  • Jump to page:

IMN logo majestic logo threadwatch logo seochat tools logo