Heim  >  Artikel  >  Backend-Entwicklung  >  php仿jQuery统制dom | php采集

php仿jQuery统制dom | php采集

WBOY
WBOYOriginal
2016-06-13 11:01:15770Durchsuche

php仿jQuery控制dom | php采集
详细情况,各位可以自行下载附件运行体验一下。
有段时间在制作PHP采集相关的程序,突然搜索到有一个比较好用的,外国人开发的类包,名叫"phpQuery",是否听这个名字就已经感觉很熟悉呢,这是一个PHP仿jQuery控制dom的好工作,利用PHP做采集必不可少的利器。

先贴出dome的部分代码:

require('phpQuery/phpQuery.php');$doc['ul > li']	->addClass('my-new-class')	->filter(':last')		->addClass('last-li')		->toReference($li);foreach($ul['> li'] as $li) {	// iteration returns PLAIN dom nodes, NOT phpQuery objects	$tagName = $li->tagName;	$childNodes = $li->childNodes;	// so you NEED to wrap it within phpQuery, using pq();	pq($li)->addClass('my-second-new-class');}


希望大家可以喜欢
Stellungnahme:
Der Inhalt dieses Artikels wird freiwillig von Internetnutzern beigesteuert und das Urheberrecht liegt beim ursprünglichen Autor. Diese Website übernimmt keine entsprechende rechtliche Verantwortung. Wenn Sie Inhalte finden, bei denen der Verdacht eines Plagiats oder einer Rechtsverletzung besteht, wenden Sie sich bitte an admin@php.cn