有谁知道通过邮政编码访问电影放映时间的任何(最好是免费的)受支持的 api?
我不相信任何现有的 api,例如 netflix 或 imdb,提供此信息。
当“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();
?>
是的,雅虎显然在 2009 年 11 月删除了他们的秘密电影 API。
似乎每个人都从 TMS Data Direct 获取数据:http ://www.tmsdatadirect.com/
不知道 Google 是否将其公开为 api,但这看起来很像您想要的。 http://www.google.com/movies?hl=en&near=90210&dq=movie+times+90210&sa=X&oi=showtimes&ct=title&cd=1
我也在寻找可以合法抓取和重新发布的放映时间。如果您不出于商业目的这样做,雅虎的声音就不会被禁止……或者这可能是我的一厢情愿。
您同意不 出于任何商业目的复制、复制、复制、出售、交易、转售或利用Yahoo! 的任何部分、使用或访问。服务
环顾四周后,我发现 Dapper (open.dapper.net) 是创建此类提要的绝佳解决方案...
这是我制作的提要,它以电影标题和邮政编码作为参数。(大多数其他可用仅通过 ZIP 搜索)
http://www.dapper.net/dapp-howto-use.php?dappName=GoogleMoviesbynameANDzip
花了大约5分钟来设置...
不确定从中刮取 html 是否合法,但是,它是我发现的最干净的伪 API。http://opensocial.flixster.com/igoogle/showtimes?date=20111025&postal=23226 - 只需用类似...的东西刮掉html
$('div.showtime', response).each(function() {
// ... process each showtime div
});
我的猜测是,你最好的选择(除非这些人有 RSS 提要)是用支持正则表达式的语言来抓取 HTML。
请注意,这很丑陋,每次他们更改代码时,您的代码都可能会损坏。
我找不到一个。
您可以尝试从 Yahoo Movies 进行屏幕抓取: http://movies.yahoo.com/showtimes/movie?z=60630&date=20090113&mid= 1810038822
z = zip code
date = year + month + day (as a string)
mid = movieID, which you will have to grab from Yahoo Movies
我也在寻找一个放映时间 API,和你一样,我还没有找到一个好的电影放映时间 API。我决定基于 Google Showtimes 编写自己的“showtime API”。请检查一下。
这是一个简单的 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/
我知道这有点老了。我认为目前还没有 api,但一些提供商确实提供了这项服务。我建议你看看西方世界媒体。
http://www.google.com/ig/api?movies=YOUR_ZIP_HERE
感谢尼克。这就是我将使用的链接。