我想從搜索字詞中使用來自imdb的php獲取海報圖像url。例如,我有搜索詞21跳街,我想回到你的圖像或只有IMDB電影網址。隨着下面的代碼,我只需要在搜索詞從搜索字詞使用php抓取imdb海報圖像
這裏獲取電影的URL是代碼,我
<?php
include("simple_html_dom.php");
//url to imdb page
$url = 'hereistheurliwanttogetfromsearch';
//get the page content
$imdb_content = file_get_contents($url);
$html = str_get_html($imdb_content);
$name = $html->find('title',0)->plaintext;
$director = $html->find('a[itemprop="director"]',0)->innertext;
$plot = $html->find('p[itemprop="description"]',0)->innertext;
$release_date = $html->find('time[itemprop="datePublished"]',0)->innertext;
$mpaa = $html->find('span[itemprop="contentRating"]',0)->innertext;
$run_time = $html->find('time[itemprop="duration"]',0)->innertext;
$img = $html->find('img[itemprop="image"]',0)->src;
$content = "";
//build content
$content.= '<h2>Film</h2><p>'.$name.'</p>';
$content.= '<h2>Director</h2><p>'.$director.'</p>';
$content.= '<h2>Plot</h2><p>'.$plot.'</p>';
$content.= '<h2>Release Date</h2><p>'.$release_date.'</p>';
$content.= '<h2>MPAA</h2><p>'.$mpaa.'</p>';
$content.= '<h2>Run Time</h2><p>'.$run_time.'</p>';
$content.= '<h2>Full Details</h2><p><a href="'.$url.'" rel="nofollow">'.$url.'</a></p>';
$content.= '<img src="'.$img.'" />';
echo $content;
?>
你有什麼這麼遠嗎? – jeroen
我會發布一些我在網上找到的代碼。我是新手在PHP中,....我將編輯並添加上面的代碼 – user1346598