有人知道通过邮编访问电影放映时间的(最好是免费)受支持的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=zh-CN&near=90210&dq=movie+times+90210&sa=X&oi=showtimes&ct=title&cd=1我也在寻找可以合法抓取和重新发布的放映时间。雅虎的声音好像如果你不是出于商业目的而这样做,那就不被禁止了...或许这只是我的一厢情愿。
您同意不为任何商业目的复制、重复、出售、交易、转售或利用 Yahoo! 服务的任何部分、使用或访问。
在寻找一段时间后,我发现Dapper(open.dapper.net)是创建此类型的Feed的绝佳解决方案...
这是我制作的Feed,它以电影标题和邮政编码作为参数。(大多数其他可用的仅按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。
请注意,这很丑陋,而且每次他们更改代码时,你的代码可能会出现问题。
我也在寻找一个放映时间的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/