【问题标题】:Scan a webpage and get the video embed url only [closed]扫描网页并仅获取视频嵌入网址 [关闭]
【发布时间】:2013-12-03 05:11:39
【问题描述】:

我有一个 PHP 搜索引擎,它已经索引了一些电影网站。现在我想在给定的网页 URL 上获取视频嵌入 URL。并将其放入 iframe 中。我将如何得到它?使用蟒蛇?并将其集成到 PHP 中?但是我将如何将 url 从 php 传递给 python 并使用 beautifulsoup?

这是我现在正在尝试的

import BeautifulSoup

html = '''http://www.kumby.com/avatar-the-last-airbender-book-3-chapter-5/'''
soup = BeautifulSoup.BeautifulSoup(html)

我用谷歌搜索过,但没有找到任何关于这个的好信息(可能是因为我不知道这被称为搜索什么),有没有人有这方面的经验并且知道如何做到这一点?

谢谢!

【问题讨论】:

  • How will i get it ? using python? and integrate it in PHP ? but how will i pass the url from php to python and use the beautifulsoup? 我觉得这是一个特别有趣的 python+PHP 教学视频的介绍。不是:(
  • @admdrew 有同样的问题吗?同样在这里伙计。 ://

标签: python beautifulsoup


【解决方案1】:
from bs4 import BeautifulSoup

html = "http://www.kumby.com/avatar-the-last-airbender-book-3-chapter-5/"
soup = BeautifulSoup(html)
l = soup.findall("embed","object","param","video")
for i in l:
  print i.string

【讨论】:

    【解决方案2】:

    您需要抓取网页并查找以下标签并获取视频链接。你不需要python来做到这一点。

    <embed> 
    <object>    
    <param> 
    <audio>
    <video>
    <source>(<video> and <audio>)
    <track> (<video> and <audio>)
    

    我做了一个小技巧来从网页上抓取所有链接,请参阅此sample

    【讨论】:

    • 您的示例是否仅适用于 php?谢谢你。
    • 这样能获取视频网址吗?
    • 它只是抓取所有 标签,如果你在这个file 中寻找 extract_links 方法,正则表达式会进行提取
    猜你喜欢
    • 2017-03-30
    • 2010-09-21
    • 2015-11-16
    • 2023-04-03
    • 2015-04-27
    • 2014-11-29
    • 1970-01-01
    • 2015-08-18
    • 2015-05-01
    相关资源
    最近更新 更多