Web scraping in Objective C

后端 未结 2 2039
误落风尘
误落风尘 2021-02-15 16:22

is there any Objective C library for parsing HTML, like python\'s BeautifulSoup? Thanks

2条回答
  •  误落风尘
    2021-02-15 16:27

    From Apple's part there is NSXMLDocument and NSXMLParser, which support tidied HTML input. (Tree-Based XML Programming Guide)

    On iOS (4.3) there's currently no NSXMLDocument available, so you'd have to use either NSXMLParser or libxml2.2.

    Some more informations on potential problems with parsing malformed HTML:
    What's the best approach for parsing XML/'screen scraping' in iOS? UIWebview or NSXMLParser?

    The most reliable solution is to use an off-screen WebView, load the HTML source into it and then access its DOM tree.

提交回复
热议问题