This is its own previous written a PHP collection class, has been used, I feel very simple and powerful, as long as the knowledge of a little selector can be collected any page, but also support HTTPS page, do a simple collection enough to use the
First, the collection of source code codes are as follows: <?php /** * Universal List Collection Class * Version V1.3 * Author: JAE / REQUIRE_ON Ce '.. /phpquery/phpquery/phpquery.php '; class querylist{ private $pageURL; &NBSP;PRIV Ate $REGARR = Array (); public $JSONARR = Array (); private $regRange; private $html; /************************************************ * Parameters: Page Address selector array block selector * "selector array" description: Format array (name =>array (selector, type),.......) &nbs P * "type" description: Value "text", "HTML", "Properties" * "block selector": First select a few chunks according to the rules, and then separate In the block to do the relevant selection *************************************************/ function querylist ($pageURL, $reGarr=array (), $regRange = ' ') { $this->p Ageurl = $pageURL; //in order to get https:// &N BSP; $ch = Curl_init (); curl_setopt ($ch, Curlopt_url, $this->pageurl); curl_setopt ($ch, Curlopt_ssl_verifypeer, false); &NBS P curl_setopt ($ch, Curlopt_ssl_verifyhost, false); curl_setopt ($ch, curlopt_returntransfer,1); &N Bsp $this->html = curl_exec ($ch); curl_close ($ch); if (!empty ($REGARR)) &NBSP ; {&NBsp $this->regarr = $REGARR; $this->regrange = $regRange; $this->getlist ();   } & Nbsp;function setquery ($regArr, $regRange = ' ') { $this->jsonarr=array (); $this->regarr = $REGARR; $this->regrange = $regRange; $this->getlist (); &NBSP, Private Function getlist () &NB Sp { $hobj = phpquery::newdocumenthtml ($this-≫html); if (!empty ($this->regrange)) & nbsp { $robj = PQ ($hobj)->find ($this->regrange); &NB Sp $i = 0; foreach ($robj as $item) { while (list ($key, $reg _value) =each ($this->regarr) ) { $iobj = PQ ($item)->find ($reg _value[0]); switch ($reg _value[1]) &NB Sp { &N Bsp &NBSP case ' text ': &NBSP ; $this->jsonarr[$i] [$key] = Trim (PQ ($iobj)->text ()); brea K case ' html ': &NBSP ; $this->jsonarr[ $I] [$key] = Trim (PQ ($iobj)->html ()); brea K default: &N Bsp $this->jsonarr[$i] [$key] = P Q ($iobj)-≫attr ($reg _value[1]); break; } & nbsp //reset array pointer & nbsp reset ($this->regarr); $i + +; , &NBSP, else { &NBSP ; while (list ($key, $reg _value) =each ($this->regarr)) { & nbsp $lobj = PQ ($hobj)->find ($reg _value[0]); $i 0; foreach ($lobj as $item) & nbsp { &NBSP;SWI TCH ($reg _value[1]) { &NBS P case ' text ': &NBSP ; $this->jsonarr[$i ++][$key] = Trim (PQ ($item)->text ()); brea K case ' HTML ': $t his->jsonarr[$i ++][$key] = Trim (PQ ($item)->html ()); brea K default: &N Bsp $this->jsonarr[$i ++][$key] = PQ ($item)->attr ($reg _value[1]); break; } & nbsp &NBSP} &N Bsp &NBsp &NBSP, } function Getjson () { &NBSP ; return Json_encode ($this->jsonarr); } { II, use example code as follows: <?php require ' Query/queryli St.class.php '; //Collect code share list for OSC, title link author $url = "Http://www.oschina.net/code/list"; $reg = Array (". Code_title a:eq (0)", "text"), "url" =>array (". Code_title a:eq (0)", "href"), "=>array" author "=>array" ("img", "title")); $rang = ". Code_list li"; $HJ = new Querylist ($url, $reg, $rang); $arr = $hj->jsonarr; Print_r ($arr); If you also want to collect the TOP40 active contributor image on the right side of the current page, get the JSON data so that you can write $reg = Array ("Portrait" =>array (". Hot_top img", "src")); $hj->setquery ($reg); $json = $hj->getjson (); Echo $json. "<hr/>"; //Mining OSC content Page Content $url = "Http://www.oschina.net/code/snippet_186288_23816 "; $reg = Array ("title" =>array ("). Qtitle H1 "," text ")," Con "=>array (". Content "," html ")); $HJ = new Querylist ($url, $reg); $arr = $hj->jsonarr; Print_r ($arr); //So many examples, is not used to do the collection is very convenient