Extract part of HTML in C/Objective-C

亡梦爱人 提交于 2020-01-06 07:14:08

问题


I need to extract the detail content of a website while preserve all formatting of the division. The section I wish to extract is:

...
<div class="detailContent"><p>
<P dir=ltr><STRONG>Hinweis</strong>: Auf ... </p>
</div> 
...

My current solution is to use HTMLParser from libxml2 and xpath to find the nodes and walk through all the nodes to reconstruct this piece of HTML. This is a long an complicated code.

I' just wondering if there is an easier solution to extract part of HTML?

Thanks.


回答1:


Simple Javascript solution: document.getElementsByClassName("detailContent")

Combine that with UIWebView's support for running Javascript and you might have a more concise solution.



来源:https://stackoverflow.com/questions/3045592/extract-part-of-html-in-c-objective-c

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!