From: http://www.cocoachina.com/macdev/objc/2010/1104/2296.html
This section parses the htmlCodeShared by cocoachina member "Yuehua Water", we hope to help developers
# Import "stringchuli. H "/* Project role: link network resolution HTML */@ implementation stringchuli // access the webpage source code-(nsstring *) urlstring :( nsstring *) value {nsurl * url = [nsurl urlwithstring: value]; nsdata * Data = [nsdata datawithcontentsofurl: url]; // solves Chinese garbled characters and uses gbknsstringencoding ENC = encode (encoding ); nsstring * retstr = [[nsstring alloc] initwithdata: data encoding: ENC]; return retstr ;}/ * function: intercept the string STR from value1 to value2: string value1 to be processed: matching string value2 on the left: matching string on the right */-(nsstring *) STR :( nsstring *) STR value1 :( nsstring *) value1 value2 :( nsstring *) value2 {// I: subscript int I of the string matching on the left in STR; // J: subscript Int J of the string matching on the right in str1; // This class can use value1 to match the string nsange range1 = [STR rangeofstring: value1]; // you can determine whether range1 matches the string if (range1.length> 0) {// convert it to nsstringnsstring * result1 = nsstringfromrange (range1); I = [self indexbyvalue: result1]; // cause: add the length of the matched string to obtain the correct subscript I = I + [value1 length];} // Delete the nsstring * str1 = [STR substringfromindex: i]; nsange range2 = [str1 rangeofstring: value2]; If (range2.length> 0) {nsstring * result2 = nsstringfromrange (range2); j = [self indexbyvalue: result2];} nsstring * str2 = [str1 substringtoindex: J]; return str2;} // subscript of the matched information obtained by filtering-(INT) indexbyvalue :( nsstring *) STR {// use the nsmutablestring class, which can append nsmutablestring * value = [[nsmutablestring alloc] initwithformat: @ ""]; nsstring * colum2 = @""; int J = 0; // print out the lower mark value for (INT I = 1; I <[STR length]; I ++) {nsstring * colum1 = [STR substringfromindex: i]; [value appendstring: colum2]; colum2 = [colum1 substringtoindex: 1]; If ([colum2 is1_tostring: @ ","]) {J = [value intvalue]; break ;}} [value release]; return J ;}@ end