Solved, a little messy, just speed. {Code...} URL: www.hkxy.edu.cn: how can I extract text and href of element a under. offer_box_wide1? Tutorial
Solved, a little messy, just speed.
(.*?)% Sim '; preg_match_all ($ pa, $ response, $ arr); $ pa =' % (.*?) % Sim '; preg_match_all ($ pa, $ response, $ arr); $ result = array (); $ number = count ($ arr [1]); for ($ I = 0; $ I <$ number; $ I ++) {$ temp = explode ('/', $ arr [1] [$ I]); // print_r ($ temp); exit (); $ result [$ temp [2] [$ I] ['src'] =' http://www.hkxy.edu.cn '. $ Arr [1] [$ I]; $ result [$ temp [2] [$ I] ['title'] = $ arr [2] [$ I];} echo JSON ($ result); function arrayRecursive (& $ array, $ function, $ apply_to_keys_also = false) {static $ recursive_counter = 0; if (++ $ recursive_counter> 1000) {die ('possible deep recursion attack');} foreach ($ array as $ key => $ value) {if (is_array ($ value )) {arrayRecursive ($ array [$ key], $ function, $ apply_to_keys_also);} else {$ array [$ ke Y] = $ function ($ value);} if ($ apply_to_keys_also & is_string ($ key) {$ new_key = $ function ($ key); if ($ new_key! = $ Key) {$ array [$ new_key] = $ array [$ key]; unset ($ array [$ key]) ;}}$ recursive_counter --;} /*************************************** * ************************ convert an array to a JSON string (compatible with Chinese characters) * @ param array $ array the array to be converted * @ return string the converted json string * @ access public ***************** **************************************** * ***/function JSON ($ array) {arrayRecursive ($ array, 'urlencode', true); $ json = json_encode ($ array); return urldecode ($ json );}
URL: http://www.hkxy.edu.cn/
:
How can I extract text and href of element a under. offer_box_wide1? Tutorial
Reply content:
Solved, a little messy, just speed.
(.*?)% Sim '; preg_match_all ($ pa, $ response, $ arr); $ pa =' % (.*?) % Sim '; preg_match_all ($ pa, $ response, $ arr); $ result = array (); $ number = count ($ arr [1]); for ($ I = 0; $ I <$ number; $ I ++) {$ temp = explode ('/', $ arr [1] [$ I]); // print_r ($ temp); exit (); $ result [$ temp [2] [$ I] ['src'] =' http://www.hkxy.edu.cn '. $ Arr [1] [$ I]; $ result [$ temp [2] [$ I] ['title'] = $ arr [2] [$ I];} echo JSON ($ result); function arrayRecursive (& $ array, $ function, $ apply_to_keys_also = false) {static $ recursive_counter = 0; if (++ $ recursive_counter> 1000) {die ('possible deep recursion attack');} foreach ($ array as $ key => $ value) {if (is_array ($ value )) {arrayRecursive ($ array [$ key], $ function, $ apply_to_keys_also);} else {$ array [$ ke Y] = $ function ($ value);} if ($ apply_to_keys_also & is_string ($ key) {$ new_key = $ function ($ key); if ($ new_key! = $ Key) {$ array [$ new_key] = $ array [$ key]; unset ($ array [$ key]) ;}}$ recursive_counter --;} /*************************************** * ************************ convert an array to a JSON string (compatible with Chinese characters) * @ param array $ array the array to be converted * @ return string the converted json string * @ access public ***************** **************************************** * ***/function JSON ($ array) {arrayRecursive ($ array, 'urlencode', true); $ json = json_encode ($ array); return urldecode ($ json );}
URL: http://www.hkxy.edu.cn/
:
How can I extract text and href of element a under. offer_box_wide1? Tutorial
The simplest method is phpQuery.
See PHP Simple html dom Parser
Http://simplehtmldom.sourceforge.net/
You can flexibly operate html like the jquery selector.