Latest 1.1
Homepage https://github.com/silence0201/HTMLParser
License MIT
Platforms ios 7.0
Authors

HTMLParser

Language
License
HTMLParser:一个简单的Html解析器Reference StackOverflow

使用说明

导入

手工导入

  1. 将项目下HTMLParser导入项目中,
  2. 点击Bulid Phases->Link FrameWork and Libraries,添加libxml2.tbdlibxml2.dylib
  3. 在项目设置中Bulid Setting->header search paths,添加$(SDKROOT)/usr/include/libxml2

Pod安装

pod 'SIHTMLParser', '~> 1.0'

使用

  1. 导入头文件

    #import "HTMLParser.h"
  2. 初始化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] ;
  3. 查询节点信息

    HTMLNode *body = [parser body] ;
    
    NSArray *array = [body findChildrenOfClass:@"cell item"] ;
    NSArray *a = [array.firstObject findChildTags:@"a"] ;
    for (HTMLNode *node in a){
        NSLog(@"%@",[node contents]) ;
    }
  4. 更多使用请查看头文件说明

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"
    }
}

Pin It on Pinterest

Share This