【问题标题】:Get image URL from rss从 rss 获取图片 URL
【发布时间】:2015-12-30 22:44:13
【问题描述】:

我想从这个 rss 文件中获取帖子的第一个图片 URL:http://www.macnotes.de/feed/

如何在 Swift 中做到这一点?

我得到了描述,标题和作者是这样的:

    let item = feedItems[indexPath.row] as MWFeedItem
    let vc = ViewController()
    vc.text.text = item.description
    vc.author.text = item.author
    vc.layer.text = item.title

【问题讨论】:

  • 您不能轻易做到,因为图像没有属性(如标题、作者等)。您需要遍历 html 内容以找到第一个 img 标记并获取它的 url。
  • @123 on github.com 寻找 html 或 xml 解析器
  • 我的回答祝你好运
  • 试试这个框架,它会让事情变得更简单:github.com/cezheng/Fuzi

标签: ios swift image rss


【解决方案1】:

正如我在 cmets 中所说,获取隐藏在内容 html 中的图像并不容易。

要实现这一点,您可以使用正则表达式来查看 img 标签的内容:

How to get all <img src> of a web page in iOS UIWebView?

希望这是有用的。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-10-04
    • 1970-01-01
    相关资源
    最近更新 更多