Objective-C寫的HTML5解析引擎:OCGumbo
OCGumbo是一個Objective-C寫的HTML5解析引擎,基于Google gumbo開源項目。
OCGumbo除了基礎的解析功能外,最大的特色是對增加了類似JQuery的查詢功能。
示例代碼:
OCGumboDocument *document = [[OCGumboDocument alloc] initWithHTMLString:htmlString]; OCGumboElement *root = document.rootElement; //document: do something with the document. //rootElement: do something with the html tree. 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"));
本文由用戶 jopen 自行上傳分享,僅供網友學習交流。所有權歸原作者,若您的權利被侵害,請聯系管理員。
轉載本站原創文章,請注明出處,并保留原始鏈接、圖片水印。
本站是一個以用戶分享為主的開源技術平臺,歡迎各類分享!