0

我想从 html 数据中获取特定标签之间的数据。

<ul>    
    <li>
        More consistent tension control and approximation with each pass than with traditional sutures.
        <ul>                    
            <li>Unique anchor designs provide multiple points of fixation along the device, allowing tension on the device to be maintained during closure.<sup><a class="reference_link" href="#22">[22]</a></sup></li>
            <li>Compared to traditional sutures, STRATAFIX™ Devices enable surgeons to easily manage tension and control approximation with each pass.<sup><a class="reference_link" href="#3">[3]</a></sup></li>
        </ul>
    </li>
<ul>

在这里,我想从<a class="reference_link" href="#3">[3]</a>我想存储该值(例如 3)中获取数据。

提前致谢。

4

4 回答 4

1

看起来互联网上有关于如何在 iOS 上解析 HTML 的相关资源;例如http://www.raywenderlich.com/14172/how-to-parse-html-on-ios

[...] iOS SDK 中包含一个方便的小库,名为 libxml2。

据我所知,这篇文章似乎有关于如何实现你想要的代码示例。

于 2013-09-12T10:44:27.743 回答
0

您可以使用 Python 使用 Beautiful Soup 模块解析 html 页面。

这是一个链接 - http://www.crummy.com/software/BeautifulSoup/

这有一些您可以遵循的示例代码。 http://www.pythonforbeginners.com/python-on-the-web/beautifulsoup-4-python/

于 2013-09-12T10:44:43.097 回答
0

如果您使用 JQuery,它可能对您有用..

 var items = $('#listTable li sup');

这里 listTable 是列表视图 ID。

于 2013-09-12T11:27:07.507 回答
0

试试漂亮的汤这里是代码

import urllib2
from bs4 import BeautifulSoup
response = urllib2.urlopen('http://www.crummy.com/software/BeautifulSoup/bs4/doc/')
html = response.read()
soup = BeautifulSoup(html_doc)
for link in soup.find_all('a'):
    link1 = link.get('href') 
    print link1

如果您使用 python 作为编码语言,就会出现这种情况。您将获得文档中存在的所有链接。这是 beatifulsoup 文档的链接:

http://www.crummy.com/software/BeautifulSoup/bs4/doc/

于 2013-09-13T13:38:32.440 回答