有电影放映时间的API吗?

71

有人知道通过邮编访问电影放映时间的(最好是免费)受支持的API吗?

我不认为任何现有的API,如Netflix或IMDb,提供此信息。


2
有人发布实际的API吗,比如Web服务?我不想做屏幕抓取。我真的很想写一个手机或iPad应用程序,它可以显示接下来2小时内附近播放的电影时间表。没有网页以这种方式显示它,而这通常是我想要看到的方式。“接下来几个小时我能看什么节目?”如果我能获取数据,我很乐意编写该应用程序。有任何线索吗?JR - user296233
13个回答

14

当 "allow_url_fopen" 被禁用时,请使用

    <?php
/**
 * Google Showtime grabber
 * 
 * This file will grab the last showtimes of theatres nearby your zipcode.
 * Please make the URL your own! You can also add parameters to this URL: 
 * &date=0|1|2|3 => today|1 day|2 days|etc.. 
 * &start=10 gets the second page etc...
 * 
 * Please download the latest version of simple_html_dom.php on sourceForge:
 * http://sourceforge.net/projects/simplehtmldom/files/
 * 
 * @author Bas van Dorst <info@basvandorst.nl>
 * @version 0.1 
 * @package GoogleShowtime
 *
 * @modifyed by stephen byrne <gold.mine.labs@gmail.com>
 * @GoldMinelabs.com 
 */

require_once('simple_html_dom.php');

$curl = curl_init(); 
curl_setopt($curl, CURLOPT_URL, 'http://www.google.ie/movies?near=dublin');  
curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);  
curl_setopt($curl, CURLOPT_CONNECTTIMEOUT, 10);  
$str = curl_exec($curl);  
curl_close($curl);  

$html = str_get_html($str);

print '<pre>';
foreach($html->find('#movie_results .theater') as $div) {
    // print theater and address info
    print "Theate:  ".$div->find('h2 a',0)->innertext."\n";
    //print "Address: ". $div->find('.info',0)->innertext."\n";

    // print all the movies with showtimes
    foreach($div->find('.movie') as $movie) {
        print "Movie:    ".$movie->find('.name a',0)->innertext.'<br />';
        print "Time:    ".$movie->find('.times',0)->innertext.'<br />';
    }
    print "\n\n";
}

// clean up memory
$html->clear();
?>

你是今天的英雄!非常感谢! - rasputin
真的,如果我可以的话,我会给+10分!很遗憾谷歌没有公开API :) - Michahell
不想听起来刻薄,但过去的记录呢? - fung
不存在了。谷歌已经删除了那个。 - Natesh bhat
1
这已经死了。谷歌杀了它。 - DoctorP
这些数据受到商业优势的控制(如果你可以操纵它,你就可以操纵人们去哪里看电影和花钱),因此公共API已经全部关闭。这只是我们生活中糟糕的世界。 - James Gardiner

8

1
@Brook在注册 http://www.tmsdatadirect.com/ 时,它会要求输入证书代码,在注册时应该提供什么值? - user507156
上面提到的未记录的YAHOO API非常好用...我已经使用了一段时间...不幸的是,YAHOO刚刚让它消失了(在11/4/09之后)...没有YAHOO的授权...而且看起来他们也不会给出!:((我希望上面的另一个想法能为我解决问题)-- Thomas - derks
雅虎刚刚删除了他们的未公开API吗?我再也无法访问它了,但我也找不到任何人谈论它(删除)的情况。 - user208374
链接已失效。 - TheCarver
仅限美国和加拿大 :-( - lrkwz

5

谢谢您的建议。我已经使用Python的beautifulsoup实现了屏幕抓取。但是,长期来看,我想避免使用它,因为这明确违反了他们的服务条款。因此,我正在寻找一种受支持/有文档记录的API。 - jhofman
1
此链接已被谷歌停用。抱歉。 - Russell Hankins

1

我也在寻找可以合法抓取和重新发布的放映时间。雅虎的声音好像如果你不是出于商业目的而这样做,那就不被禁止了...或许这只是我的一厢情愿。

您同意不为任何商业目的复制、重复、出售、交易、转售或利用 Yahoo! 服务的任何部分、使用或访问。


1

死了,不再工作。 - James Gardiner

1

3
谷歌封锁了这个 Feed,现在无法在这里使用。 - Gabriel S.

1

这个链接似乎已经失效了。 - Russell Hankins
我更新了链接。 - Samg
经过审核您的更改后,我撤回了之前的负面评论并点赞了这个答案。 - Russell Hankins

1

0

我猜你最好的选择(除非这些人有RSS源)就是使用支持正则表达式的语言来爬取HTML。

请注意,这很丑陋,而且每次他们更改代码时,你的代码可能会出现问题。


1
不幸的是,它们中没有一个有rss。使用一个不错的HTML解析器进行爬取并不难。但我更担心违反服务条款而不是偶尔需要更新代码。 - jhofman

0

我也在寻找一个放映时间的API,就像你一样,我没有找到一个好的电影放映时间的API。因此,我决定编写自己的“放映时间API”,基于Google Showtimes。请查看一下。

这是一个简单的PHP脚本,但它“做了它应该做的事情”:

    <?php
/**
 * Google Showtime grabber
 * 
 * This file will grab the last showtimes of theatres nearby your zipcode.
 * Please make the URL your own! You can also add parameters to this URL: 
 * &date=0|1|2|3 => today|1 day|2 days|etc.. 
 * 
 * Please download the latest version of simple_html_dom.php on sourceForge:
 * http://sourceforge.net/projects/simplehtmldom/files/
 * 
 * @author Bas van Dorst <info@basvandorst.nl>
 * @version 0.1 
 * @package GoogleShowtime
 */

require_once('simple_html_dom.phps');

$html = new simple_html_dom();
$html->load_file('http://www.google.nl/movies?mid=&hl=en&near=1400AB');

print '<pre>';
foreach($html->find('#movie_results .theater') as $div) {
    // print theater and address info
    print "Theate:  ".$div->find('h2 a',0)->innertext."\n";
    print "Address: ". $div->find('.info',0)->innertext."\n";

    // print all the movies with showtimes
    foreach($div->find('.movie') as $movie) {
        print "\tMovie:    ".$movie->find('.name a',0)->innertext.'<br />';
        print "\tTime:    ".$movie->find('.times',0)->innertext.'<br />';
    }
    print "\n\n";
}

// clean up memory
$html->clear();

?> 

示例: http:// code.basvd.nl/showtime_grabber_0.1/Google_showtime.php

下载 simple_html_dom.php: http:// code.basvd.nl/showtime_grabber_0.1/


9
请注意,尽管该工具可以正确提取谷歌的内容,但完全违反了谷歌的服务条款。请谨慎使用。 - Gabriel S.

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接