/OCGumbo

An Objective-C HTML5 parser.

Primary LanguageObjective-CApache License 2.0Apache-2.0

OCGumbo - An Objective-C HTML5 parser.

OCGumbo is an Objective-C wrapper of the Google Gumbo.

Basic Usage

  1. Add Gumbo sources or lib to your project.
  2. Add OCGumbo file and import "OCGumbo.h", then use OCGumboDocument to parse an html string.
OCGumboDocument *document = [[OCGumboDocument alloc] initWithHTMLString:htmlString];
OCGumboElement *root = document.rootElement;
//document: do something with the document.
//rootElement: do something with the html tree.

Extension

Now, OCGumbo add more Query support, add "OCGumbo+Query.h" and enjoy it.

####Query APIs####

.Query();
.attr();
.text();
.find();
.children();
.parent();
.parents();
.first();
.last();
.get();
.index();
.hasClass();

####Examples:####

NSLog(@"options: %@", document.Query(@"body").find(@"#select").find(@"option"));
        
NSLog(@"title: %@", document.Query(@"title").text());
        
NSLog(@"attribute: %@", document.Query(@"select").first().attr(@"id"));

NSLog(@"class: %@", document.Query(@"#select").parents(@".main"));