郵便番号で映画の上映時間にアクセスするための (できれば無料の) サポートされている API を知っている人はいますか?
netflix や imdb などの既存の API がこの情報を提供しているとは思えません。
「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();
?>
そう、Yahoo はどうやら 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
申し訳ありませんが、質問を投稿する前にもう少し検索する必要がありました。
del.icio.us でクリエイティブな検索を行ったところ、文書化されていない yahoo! が明らかになりました。ムービー API (サンプル API 呼び出し)。
いい感じ。
少し調べてみたところ、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
});
私も合法的にスクレイピングして再公開できる上映時間を探しています。Yahoo は、営利目的でなければ禁止されていないように聞こえますが、それは私の希望的観測かもしれません。
あなたは 、Yahoo ! サービス
見つかりません。
Yahooムービーからスクリーンスクレイピングを試すことができます: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/
私の推測では、(これらの人が RSS フィードを持っていない限り) そのための最善の策は、正規表現をサポートする言語で HTML をスクレイピングすることでしょう。
それは醜いことであり、彼らがコードを変更するたびに、あなたのコードが壊れる可能性があります。
私はこれが少し古いことを知っています。このための API はまだないと思いますが、一部のプロバイダーはこのサービスを提供しています。West World Mediaをご覧になることをお勧めします。
http://www.google.com/ig/api?movies=YOUR_ZIP_HERE
ニックに感謝します。それが私が使用するリンクです。