从IMDB获取电影费率表

时间:2012-04-28 16:50:58

标签: php regex

我需要从IMDB表单图像alt

获取电影评级表
<img width="44" height="15" title="PG_13" class="absmiddle" src="http://i.media-imdb.com/images/SF9c87441dc1ac3081c7de5a78d8864764/certificates/us/pg_13.png" **alt="PG_13"**>

我的代码(错误):

$arr['rate'] = $this->match('/<img class=\"absmiddle\" src=\"\(.*?)\" alt=\"\(.*?)">/ms', $html, 1);

1 个答案:

答案 0 :(得分:0)

$text = '<img width="44" height="15" title="PG_13" class="absmiddle" src="http://i.media-imdb.com/images/SF9c87441dc1ac3081c7de5a78d8864764/certificates/us/pg_13.png" alt="PG_13">';
preg_match('<img[^<]+class="absmiddle" src="([^"]+)" alt="([^"]+)"/i', $text, $a);
$src = $a[1];
$alt = $a[2];