[PHP±Ê¼Ç]PHPQueryÒ»¸ö´¦ÀíDOMµÄÀûÆ÷
PHPQueryÊÇÒ»¸öÀàËÆÓÚJQueryµÄÌṩÍê³ÉµÄ¶ÔDOMÎĵµ²Ù×÷µÄÒ»Ì׳ÌÐò¡£
¹Ù·½µØÖ·£ºhttp://code.google.com/p/phpquery/
PHPQueryµÄʹÓÃÒ»°ã¹ý³Ì£º
1 ¼ÓÔØÎĵµ£¨HTML,XMLµÈ£©
ʹÓÃÒÔϵĺ¯Êý¼ÓÔØ£¬µ±È»Ö®Ç°ÒªÓà include ¡®phpQuery/phpQuery.php¡¯ ; ½«PHPQuery ³ÌÐò´úÂë °üº¬µ½×Ô¼ºµÄ³ÌÐòÖÐÀ´¡£
phpQuery::newDocument($html, $contentType = null)
phpQuery::newDocumentFile($file, $contentType = null)
phpQuery::newDocumentHTML($html, $charset = 'utf-8')
phpQuery::newDocumentXHTML($html, $charset = 'utf-8')
phpQuery::newDocumentXML($html, $charset = 'utf-8')
phpQuery::newDocumentPHP($html, $contentType = null)
phpQuery::newDocumentFileHTML($file, $charset = 'utf-8')
phpQuery::newDocumentFileXHTML($file, $charset = 'utf-8')
phpQuery::newDocumentFileXML($file, $charset = 'utf-8')
phpQuery::newDocumentFilePHP($file, $contentType)
2 pq() º¯ÊýµÄʹÓãº
pq($param, $context = null);
pq() º¯ÊýÓÐÈý¸öÓÃ;£¨¹Ù·½Èç´Ë˵µÄ£©
1£©importing markup µ¼Èë±ê¼Çµ½µ±Ç°»òÕßÖ¸¶¨µÄÎı¾ÖУ¨$contextÖ¸¶¨£©
2£©Running Queries ¶Ôµ±Ç°µÄÄÚÈݽøÐвÙ×÷
3£©Wrapping DOMNodes with phpQuery objects ½«µ±Ç°ÎĵµÖеÄij¸ö±êÇ©Ñ¡ÖУ¬·µ»ØÒ»¸öÑ¡¶¨±êÇ©ÄÚÈݵÄphpQuery¶ÔÏó
ÎÒµÄÒ»¸ö²Ù×÷ʵÀý£º
»ñÈ¡¡°Ö¸¼â¿ì¸Ð¡±µÄÊ×Ò³£¬²¢½«ÆäÖÐÊôÓÚÎÄÕµÄÁ¬½ÓÊä³ö¡£
´úÂë:
<?php
include 'phpQuery/phpQuery.php'; phpQuery::newDocumentFile('http://mokch.info');
$artlist = pq(".post");
foreach($artlist as $li){
echo pq($li)->find('h2')->find('a')->attr('href').'<br />';
}
?>
×ܽ᣺ÓÃPHPQueryÄܹ»ºÜ·½±ãµÄ¸ù¾ÝHTML±êÇ©´¦ÀíÒ³ÃæÉϵÄÄÚÈÝ£¬ÔÚ²»ÊìϤÕýÔò±í´ïʽµÄÇé¿öÏ£¬ÍêÈ«¿ÉÒÔÀûÓÃPHPQueryдһ¸ö²É¼¯µÄ³ÌÐò¡£phpQuery,ÕýºÏÎÒÒ⣬ÏÂÒ»½×¶Î½«Ñо¿£¬ÈçºÎ½«²É¼¯µÄÄÚÈÝ£¬µ¼Èëµ½wordpress³ÌÐòÊý¾Ý¿âµÄpost±í¡£
ÍƼöÐÅÏ¢
- ¡¾ÊÓƵ²¥·Å¡¿JplayerÊÓƵ²¥·ÅÆ÷µÄʹÓÃ
- memcacheÄÚ´æÔÀí
- Memcache¼¼Êõ·ÖÏí£º½éÉÜ¡¢Ê¹Óᢴ洢¡¢Ëã·¨¡¢ÓÅ»¯....
- php³£ÓÃÕýÔò±í´ïʽ
- phpÐÔÄܼà²âÄ£¿éXHProf
- ÈÃCI¿ò¼ÜÖ§³Öservice²ã
- ʹÓÃPHPÉú³É´øLOGOµÄ¸öÐÔ»¯¶þάÂëͼÏñ
- ¹ØÓÚCodeIgniterÄã¿ÉÄܲ»ÖªµÀµÄ5¸ö֪ʶµã
- Memcache ºÁÃ뼶³¬Ê±¼°ÆäËû³£¼ûÎÊÌâ»ã×Ü
- [PHP±Ê¼Ç]PHPQueryÒ»¸ö´¦ÀíDOMµÄÀûÆ÷
ÈÈÃÅÐÅÏ¢
- nohup: redirecting stderr to stdou....
- ʹÓÃlog_formatΪNginx·þÎñÆ÷ÉèÖøüÏêϸµÄÈÕÖ¾¸ñʽ
- jquery easyUI--dataGrid-Json
- [Ô´´]·ÂGoogle Reader¡¢ÐÂÀË΢²©¡¢ÌÚѶ΢²©µ....
- ÀûÓÃKeepalived+mysql¹¹½¨¸ß¿ÉÓÃMySQLË«Ö÷×Ô¶....
- Nginx+keepalivedʵÏÖ¸ºÔؾùºâºÍË«»úÈȱ¸¸ß¿ÉÓÃ
- jqueryʵÏÖÒ³Ãæ¼ÓÔؽø¶ÈÌõ
- Rolling cURL: PHP²¢·¢×î¼Ñʵ¼ù
- codeigniter ·ÓÉÖÕ¼«ÓÅ»¯(url rewrite)
- linuxÏÂÉèÖÃsshÎÞÃÜÂëµÇ¼
×î½ü¸üÐÂ
- PHP»ñÈ¡Óû§µÄÕæʵIP£¬²¢ÅжÏÊÇ·ñÄÚÍøIP
- PHP ´íÎóÈÕÖ¾ error_log
- ÀûÓÃbigpipe»úÖÆʵÏÖÒ³ÃæÄ£¿éµÄÒì²½äÖȾ chunked¼¼Êõ
- php¿ØÖÆÎļþÏÂÔØËÙ¶È
- js + php ¶ÁÈ¡¡¢²¥·ÅÊÓƵÁ÷ ¼æÈÝfirefox£¬c....
- ¡¾ÊÓƵ²¥·Å¡¿JplayerÊÓƵ²¥·ÅÆ÷µÄʹÓÃ
- UNICODE Óë UTF-8 µÄ¹Øϵ
- memcacheÄÚ´æÔÀí
- Memcache¼¼Êõ·ÖÏí£º½éÉÜ¡¢Ê¹Óᢴ洢¡¢Ëã·¨¡¢ÓÅ»¯....
- phpʹÓÃmb_detect_encoding¼ì²â×Ö·û´®±àÂë
ÆÀÂÛ