Grabbing Data

Discussion in 'PHP' started by Vidzo, Jan 25, 2012.

  1. #1
    I would like to know how to "grab" the price from this webpage. Here is a sample of the html...

    
    <td id="currentPrice_item3874365" class="price" style="padding:2px">39.99</td>
    
    Code (markup):
    Please take into consideration that the "id" tag will change with the item number.
     
    Vidzo, Jan 25, 2012 IP
  2. Vidzo

    Vidzo Peon

    Messages:
    11
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #2
    I can grab the URL but I don't know how to create the preg_match for variable data tags.

    Anyone?
     
    Vidzo, Jan 27, 2012 IP
  3. Alex Roxon

    Alex Roxon Active Member

    Messages:
    424
    Likes Received:
    11
    Best Answers:
    7
    Trophy Points:
    80
    #3
    preg_match('/<td[^>]+class\="price\"[^>]{0,}>([^<]{0,})<\/td>/i', $html, $price);
    PHP:
    Untested, but the price should be found in $price[1] - $html is obviously the page source.
     
    Alex Roxon, Jan 27, 2012 IP