抓取 YouTube XML 以通过 SimpleXML 嵌入—我哪里出错了?

发布于 2024-08-20 12:22:39 字数 1144 浏览 5 评论 0原文

我正在尝试使用 此查询 通过 XML 查找我想要的精确视频,然后我希望使用 SimpleXML 解析这些值并将它们插入 DOM 通过此方法

早些时候,我在从以下位置提取值时遇到了一个奇怪的问题:

<media:player url='http://www.youtube.com/watch?v=ikACkCpJ-js&amp;feature=youtube_gdata'/>

当将此值用于嵌入 src 和参数值时,我只是嵌入了一个白屏。由于某种原因,源代码包含完整的参数,但 DOM 实际上省略了结束“embed”和“param”标签。控制台抛出错误。疯狂随之而来。不好。

我能找到的唯一适用于嵌入的 URL 值在这里:

<media:content url='http://www.youtube.com/v/ikACkCpJ-js?f=videos&amp;app=youtube_gdata' type='application/x-shockwave-flash' medium='video' isDefault='true' expression='full' duration='159' yt:format='5'/>

不幸的是,当我对 simplexml_load_file('feed file') 中存储的值运行 print_r 时,我得到以下内容: http://drp.ly/lmf2J 呃。这些值恰好在我需要达到的实际值之前停止。

显然,我在处理这个问题或执行过程中搞砸了一些事情。你能帮我一下吗?

I'm trying to use this query to find the precise videos I want via XML, then I'm looking to parse the values with SimpleXML and insert them in the DOM via this method.

I was experiencing a strange problem earlier when pulling the value from:

<media:player url='http://www.youtube.com/watch?v=ikACkCpJ-js&feature=youtube_gdata'/>

When using this value for the embed src and param value, I simply get a white screen embedded. For some reason, the source code included the full parameters, but the DOM actually leaves out the closing "embed" and "param" tags. Console throws an error. Madness ensues. No good.

The only URL value I can find that works for the embed is in here:

<media:content url='http://www.youtube.com/v/ikACkCpJ-js?f=videos&app=youtube_gdata' type='application/x-shockwave-flash' medium='video' isDefault='true' expression='full' duration='159' yt:format='5'/>

Unfortunately, when I run a print_r on the value stored in simplexml_load_file('feed file'), I get the following: http://drp.ly/lmf2J Ugh. The values stop just before the actual value I'm needing to get to.

I'm obviously screwing something up here in the way I'm approaching this problem or in my execution. Can you help me out?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

终陌 2024-08-27 12:22:39

好吧,看起来我能够表现得好像该元素确实存在一样,以获得结果。

又卡住了。去问另一个问题。

Well, looks like I was able to act as if that element really did exist in order to get the result.

Stuck again. Off to ask another question.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文