在C/Objective-C中提取HTML的一部分 [英] Extract part of HTML in C/Objective-C

查看:123
本文介绍了在C/Objective-C中提取HTML的一部分的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要提取网站的详细内容,同时保留该部门的所有格式.我要提取的部分是:

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> 
...

我当前的解决方案是使用libxml2和xpath中的HTMLParser查找节点,并遍历所有节点以重建这部分HTML.这是一个很长的复杂代码.

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.

我只是想知道是否有更简单的解决方案来提取HTML的一部分?

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

谢谢.

推荐答案

简单的Javascript解决方案:document.getElementsByClassName("detailContent")

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

结合UIWebView对运行Javascript的支持,您可能会有一个更简洁的解决方案.

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

这篇关于在C/Objective-C中提取HTML的一部分的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆