Informations from imdb with file_get_content and explode problem

Started on the old forum in May 2013 · view the original in the archive · old links redirect here

6 replies · 516 views · started 13 years ago · 1 min read

5 participants
cedry2k Junior · 15 posts #1

Hi, I'm trying to make an plugin that grab the movie info from imdb and displays them on a page. The problem is that I can't get the poster. This is my code:

$url = file_get_contents("http://www.imdb.com/title/tt1980209/");
$poster = explode('<img height="317" width="214" src="', $url );
$poster = explode('" itemprop="image" />', $poster[1]);

$picture = '<img height="170" width="150" src="'.$poster[0].'" />';
echo $picture;

In the "View page source" I see only this: <img height="170" width="150" />

The imdb page source html for poster is this:

<img height="317"
width="214"
alt="Pain & Gain (2013) Poster"
title="Pain & Gain (2013) Poster"
src="http://ia.media-imdb.com/images/M/MV5BMTU0NDE5NTU0OV5BMl5BanBnXkFtZTcwMzI1OTMzOQ@@._V1_SY317_CR0,0,214,317_.jpg"
itemprop="image" />

What is the problem?

do{ beer++ }while(sober); ===//\==\//=== while($lifes_a_bitch == true) { live(); } die;

something else Fellow · 2,296 posts #3

cedry2k wrote: What is the problem?

First Problem:

$poster = explode('<img height="317" width="214" src="', $url );

It should be alt=" not src="

Second problem: You need to strip all newline symbols \n \r and white-space etc as other wise you will not get a match for your exploding

kevk3v Senior · 332 posts #5

Maybe he isn't good with regular expressions or because explode is faster 😛

Mobile chat, iphone chat, android chat, chat, rooms http://www.aiochat.com

analyzer Developer · 104 posts #6

Or maybe he's trying to make something different..

It's n0t that i am afraid to die. Its just that if i die, wh0 wilL loVe her as muCh as i Do?

cedry2k Junior · 15 posts #7

Actually I was thinking to try the imdbapi, because I think it will be faster than the explode...

do{ beer++ }while(sober); ===//\==\//=== while($lifes_a_bitch == true) { live(); } die;

Write your reply now; next you create a free account (or sign in) and it is posted right away. Sign in to reply.

Similar topics

Keyboard shortcuts

g f
Go to forums
g h
Go to your feed
g m
Go to messages
r
Reply (in a topic)
/
Search
j
Next post
k
Previous post
?
This list
Ctrl/⌘ + Enter
Send what you are writing
Ctrl/⌘ + B / I
Bold / italic while writing
Esc
Close