A web parser for iOS to parser a particular html tag by id or class elements
Webparser is now available for CocoaPods! Simply include 'webparser' in your podfile.
Suppose, we have a file like the following as HTML tag
<divid="page" class="configurable story " data-story-id="world-europe-46955006"><divrole="main"><divclass="container-width-only"></div></div</div>you can parse the page by either the id or class parameter
import webparser
leturl= parser.init()
url.get_the_page_info(body_prase:["page","container-width-only"], return_method:"HTML", url_string: url_string!,{(title, description, previewImage,body_div)->Voidinprint(body_div["article_body"])}, failure:{(errorMessage)->Voidinprint(errorMessage)})Initialise parser.init()
Now you can use the function
get_the_page_info(body_prase:[String],return_method:String,url_string:URL,_ completion:@escaping((_ title: String?, _ description: String?, _ previewImage: String?,_ body_div:[String:[String]])-> Void), failure:@escaping((_ errorMessage: String)-> Void))Input parameters:
- body_prase --> String Array eg) ["page","container-width-only"] 2)return_method ---> String which will accepet either "HTML" or "TEXT 3)url_string ---> URL datatype
Output Parameter:
- title: String?, --> will return Titte of the page
- description: String?,--> will return Description of the page
- previewImage:: String? will return preview image of the page just like seen in facebook
- body_div:[String:[String]] --> which will parse the url will return a array dictionary with key ad Input parameter given in body_prase