到目前为止,我编写的 cURL 代码在自动将我登录到网站后显示了我想要的页面,但是我陷入了屏幕抓取的问题。我现在想从这些数据中整理出更多信息。这是我想要从页面中整理出来的内容:
<div class="quantity">
Avail. Quantity:<span>75</span>
</div>
我特别想获取
内的数字,在本例中为 75
。我怎样才能用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?
发布评论
评论(1)
您可以使用
DOMDocument
或更简单的库前端之一,例如phpQuery
或QueryPath
。然后就像使用 CSS 选择器一样简单:(请注意,页面检索已内置于此,但您也可以仅传递
$html
变量。)You can use
DOMDocument
or one of the simpler library frontends likephpQuery
orQueryPath
. Then it's as easy as using a CSS selector:(Note that page retrieval is already built-in here, but you could also just pass your
$html
variable.)