PHP captures webpage-specific data. I want to capture webpage: webpage? Thank you. if you need to read this reply, please log on or register CSDN! PHP captures webpage-specific data
I want to capture the specific data of the table gripm2.5on the webpage: http://www.pm2d5.com/city/xg_wangjiao.html,
Is there any efficient way? Thank you ..
------ Solution --------------------
I am stupid, but my regular expression is really bad.
PHP code
// $ Html is the content of www.pm2d5.com/city/xg_wangjiao.html. here, you can write it like pattern = "/[\ s \ S] +? <\/Td>/I "; preg_match_all ($ pattern, $ html, $ tdTag); // var_dump ($ tdTag ); // HTML tag $ deleteStrHeader = ''; $ deleteStrFooter =''; $ pmvalue = array (); foreach ($ tdTag [0] as $ key => $ value) {// if ($ key + 1) % 6 = 0) when traversing to the column pm2.5) {// remove the header and tail HTML tag $ noHeaderStr = str_replace ($ deleteStrHeader, '', $ value); $ cleanStr = str_replace ($ deleteStrFooter,'', $ noHeaderStr ); // Convert to float type $ pmvalue [] = (float) trim ($ cleanStr) ;}} var_dump ($ pmvalue );