Så lavede jeg lige en lappeløsgning, så det også virker på netflix.com og de øvrige sider jeg har prøvet indtil videre:
function not_finished_parseDescription($html) {
$strhttp = $html;
if ($strhttp != "") {
$strpos = strpos(strtolower($strhttp),"<head>");
if ($strpos !== FALSE) {
$strhttp = substr($strhttp,$strpos+strlen("<head>"));
$strpos = strpos(strtolower($strhttp),"</head>");
if ($strpos !== FALSE) {
$strhttp = substr($strhttp,0,$strpos);
}}}
if ($strhttp != "") {
$strpos = strpos(strtolower($strhttp),"name=description");
$strpos2 = strpos(strtolower($strhttp),"name=\"description\"");
if ($strpos !== FALSE) {
$strpos_end = strpos(strtolower($strhttp),">",$strpos);
$strhttp = substr($strhttp,0,$strpos_end+1);
$strpos_start = strrpos(strtolower($strhttp),"<");
$strhttp = substr($strhttp,$strpos_start);
}
else if ($strpos2 !== FALSE) {
$strpos_end = strpos(strtolower($strhttp),">",$strpos2);
$strhttp = substr($strhttp,0,$strpos_end+1);
$strpos_start = strrpos(strtolower($strhttp),"<");
$strhttp = substr($strhttp,$strpos_start);
}
}
return parseDescription($strhttp);
}
function parseDescription($html) {
// Get the 'content' attribute value in a <meta name="description" ... />
$matches = array();
// Search for <meta name="description" content="Buy my stuff" />
preg_match('/<meta.*?name=("|\')description("|\').*?content=("|\')(.*?)("|\')/i', $html, $matches);
if (count($matches) > 4) {
return trim($matches[4]);
}
// Order of attributes could be swapped around: <meta content="Buy my stuff" name="description" />
preg_match('/<meta.*?content=("|\')(.*?)("|\').*?name=("|\')description("|\')/i', $html, $matches);
if (count($matches) > 2) {
return trim($matches[2]);
}
// No match
return null;
}