如何在 PHP Simple HTML DOM Parser 中使用 Xpath [英] How to use Xpath in PHP Simple HTML DOM Parser

查看:35
本文介绍了如何在 PHP Simple HTML DOM Parser 中使用 Xpath的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在学习使用 PHP Simple HTML DOM Parser 和 Xpath 进行抓取.根据此处给出的变更日志 http://sourceforge.net/news/?group_id=218559.PHP 简单 HTML DOM 解析器支持从 Firebug 生成的 xpath.但我无法弄清楚如何使用它.谁能告诉我一个相同的例子...

I am learning scraping using the PHP Simple HTML DOM Parser and Xpath. Accroding to the changelog given here http://sourceforge.net/news/?group_id=218559. The PHP SImple HTML DOM Parser supports xpath generated from Firebug. But I am not able to figure out how to use it. Can anyone show me an example of the same...

推荐答案

find 函数.http://simplehtmldom.sourceforge.net/manual.htm#section_find

$content = file_get_html($link);

$elems = $content->find("/html/body/div/div");

这篇关于如何在 PHP Simple HTML DOM Parser 中使用 Xpath的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆