Latest | 1.1 |
---|---|
Homepage | https://github.com/silence0201/HTMLParser |
License | MIT |
Platforms | ios 7.0 |
Authors |
HTMLParser
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安装
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
HTMLParser is available under the MIT license. See the LICENSE file for more info.
Latest podspec
{ "name": "SIHTMLParser", "version": "1.1", "summary": "HTMLParser", "description": "An Objective-C wrapper to parse HTML", "homepage": "https://github.com/silence0201/HTMLParser", "license": { "type": "MIT", "file": "LICENSE" }, "authors": { "Silence": "[email protected]" }, "platforms": { "ios": "7.0" }, "source": { "git": "https://github.com/silence0201/HTMLParser.git", "tag": "1.1" }, "source_files": [ "HTMLParser", "HTMLParser/**/*.{h,m}" ], "exclude_files": "HTMLParser/Exclude", "libraries": "xml2", "xcconfig": { "HEADER_SEARCH_PATHS": "$(SDKROOT)/usr/include/libxml2" } }
Fri, 24 Feb 2017 03:40:08 +0000