JQuery的PHP函数

Moe*_*eet 4 php jquery jquery-selectors

我想知道是否有类似JQuery的$('element.selector')为PHP实现的?

当我从CURL和我从远程站点获取HTML代码时,我想在发送到HTML之前仅选择我想要的标签.

谢谢

Gum*_*mbo 14

PHP简单的HTML DOM解析器也有类似的功能:

// Create DOM from URL or file
$html = file_get_html('http://www.google.com/');

// Find all images 
foreach($html->find('img') as $element) 
       echo $element->src . '<br>';

// Find all links 
foreach($html->find('a') as $element) 
       echo $element->href . '<br>';
Run Code Online (Sandbox Code Playgroud)


use*_*725 5

或者也许是Querypath(http://querypath.org/)?刚看过它,它看起来很酷.