Thomas
Thomas

Reputation: 2386

screen scraping with curl

so far my cURL code i have written displays the page that I would like after it automatically logs me into a website, however i am stuck on the issue of screen scraping. I would like to now sort through some more information from this data. here is what i want to sort out of the page:

<div class="quantity">
    Avail. Quantity:<span>75</span>
</div>

I specifically would like to grab the number inside the <span> which in this case would be 75. how could i do this with curl?

Any suggestions on how to do this?

Upvotes: 0

Views: 824

Answers (1)

mario
mario

Reputation: 145482

You can use DOMDocument or one of the simpler library frontends like phpQuery or QueryPath. Then it's as easy as using a CSS selector:

print htmlqp($url)->find(".quantity span")->text();

(Note that page retrieval is already built-in here, but you could also just pass your $html variable.)

Upvotes: 3

Related Questions