loadHTML($html); libxml_clear_errors(); // Use DOMXPath to query the page content $xpath = new DOMXPath($doc); // Look for the tag containing the SoundCloud track ID $metaTags = $xpath->query("//meta[contains(@content, 'soundcloud://sounds:')]"); if ($metaTags->length > 0) { // Extract the content attribute from the meta tag $content = $metaTags->item(0)->getAttribute('content'); // Extract the track ID using a regular expression if (preg_match('/soundcloud:\/\/sounds:(\d+)/', $content, $matches)) { $track_id = $matches[1]; // Build the iframe HTML $iframe = ''; // Get the artist name and track title from the meta tags $artistMeta = $xpath->query("//meta[@property='og:site_name']"); $trackMeta = $xpath->query("//meta[@property='og:title']"); $artist_name = "Unknown Artist"; $track_title = "Unknown Track"; if ($artistMeta->length > 0) { $artist_name = $artistMeta->item(0)->getAttribute('content'); } if ($trackMeta->length > 0) { $track_title = $trackMeta->item(0)->getAttribute('content'); } // Build the song details HTML $details = '
'; $details .= '' . htmlspecialchars($artist_name) . ' ยท '; $details .= '' . htmlspecialchars($track_title) . ''; $details .= '
'; // Output the iframe and details echo $iframe; echo $details; } else { echo "Track ID not found in the meta tag.\n"; } } else { echo "No meta tag containing track data found.\n"; } ?>