【发布时间】:2017-05-07 22:53:18
【问题描述】:
我正在尝试使用 Nokogiri 从 YouTube 的 XML Atom 提要中提取 URL。
我很幸运地提取了 id 的命名空间,但在提取 URL 时遇到了困难。例如,YouTube 的 API 提供了三个不同的 <media:thumbnail> 标签和三个不同的 <media:content> 标签。您可以在下面看到这些标签中的任何一个都没有显示 URL。我的目标是分别从第一个 <media:thumbnail> 和 <media:content> 中提取 URL。
这是我的代码:http://pastie.org/1881669
这是一个条目在终端中的输出:
{:group=>\"ComedyThe OMG Cat or the WTF cat - funny gobsmacked cat. The cats name is \\\"Choco\\\" and if i told you what she was looking at, I would have to kill you!!!The OMG Cat, omg cat, wtf cat, cat, cats, cat fail, the wtf cat, cute cats, cute animals, funny cats, funny cat video, omg, wtf, gobsmacked cat, gobsmacked, two girls one cup, reactionThe OMG Cat\", :category=>\"Comedy\", :content=>\"\", :description=>\"The OMG Cat or the WTF cat - funny gobsmacked cat. The cats name is \\\"Choco\\\" and if i told you what she was looking at, I would have to kill you!!!\", :keywords=>\"The OMG Cat, omg cat, wtf cat, cat, cats, cat fail, the wtf cat, cute cats, cute animals, funny cats, funny cat video, omg, wtf, gobsmacked cat, gobsmacked, two girls one cup, reaction\", :player=>\"\", :thumbnail=>\"\", :title=>\"The OMG Cat\"}]"
【问题讨论】:
-
你能提供一段XML文件吗?
-
如果您编辑您的问题并在此处提供代码的工作部分,而不是指望我们追查它,这将有所帮助。如果那个馅饼消失了,它也将留在你的问题中而不是死去。而且,我将支持@taro 的请求,即您提供 XML 的缩减示例。没有它,我们无法为您提供帮助。