CocoaPods trunk is moving to be read-only. Read more on the blog, there are 14 months to go.
| TestsTested | ✗ |
| LangLanguage | Obj-CObjective C |
| License | MIT |
| ReleasedLast Release | Aug 2017 |
Maintained by Silence0201.
HTMLParser:一个简单的Html解析器Reference StackOverflow
HTMLParser导入项目中,Bulid Phases->Link FrameWork and Libraries,添加libxml2.tbd或libxml2.dylib
Bulid Setting->header search paths,添加$(SDKROOT)/usr/include/libxml2
pod 'SIHTMLParser', '~> 1.0'
导入头文件
#import "HTMLParser.h"初始化Parser
NSError *error = nil;
NSString *path = [[NSBundle mainBundle]pathForResource:@"test" ofType:@"html"] ;
NSData *htmlData = [NSData dataWithContentsOfFile:path] ;
HTMLParser *parser = [[HTMLParser alloc] initWithData:htmlData error:&error] ;查询节点信息
HTMLNode *body = [parser body] ;
NSArray *array = [body findChildrenOfClass:@"cell item"] ;
NSArray *a = [array.firstObject findChildTags:@"a"] ;
for (HTMLNode *node in a){
NSLog(@"%@",[node contents]) ;
}更多使用请查看头文件说明
HTMLParser is available under the MIT license. See the LICENSE file for more info.