Pull data from external site
I tried look this up but I couldn't seem to find what I need.
I want to pull the movie synopsis from Apple.com/trailers pages.
This seems like it should be fairly easy considering that they are stored in a META tag near the top of each page no matter how it is displayed to the user (some pages use an old layout, some new).
If I can get ahold of that line of code I just posted, I know how to split it up with PHP to get just the synopsis text, but I can't seem to figure out how to pull just that meta tag. I'd like to avoid pulling the whole page source if possible.
<meta name="Description" content="synopsis_text" />
If your host does not have allow_url_fopen enabled, you'll probably have to use the cURL functions to grab the HTML content, then use DOMDocument->loadHTML() instead of DOMDocument->loadHTMLFile().
$dom = new DOMDocument();
$metas = $dom->getElementsByTagName('meta');
foreach($metas as $meta)
if(strtolower($meta->getAttribute('name')) == 'description')
$desc = $meta->getAttribute('content');
Users Browsing this Thread
There are currently 1 users browsing this thread. (0 members and 1 guests)