we want to create a script that gather data from url.
I have read a lot about this in internet, but cant manage to make it work.
The data i need to get is a key that is found on a specific url.
playlist: '/get_file.php?stream=WyJPRUU1TkRWRk5VUXpSVFJGUXpFM1FUb3hNemcxTWpFME5Ua3lMamMzTlRRNlpHWTBZV00wTUdVNU16ZzJObVZqTkdFNU9HSXdaVEptT0dGaE5XUmhaREUzTUdVd09UUTJaZz09IiwicmVnIl0=',
i need that long key that is after **stream=**
and ends with
',
we saw some examples, like:
<?php
$link = file_get_contents("http://www.domain.com");
$file = strip_tags($link, "<div>");
preg_match_all("/<div/>(?:[^<]*)<\/div>/is", $file, $content);
print_r($content);
?>
but its not our case. Please help us to get this data from url, thnx for reading.
$url = 'www.example.com';
$url .='/get_file.php?stream=WyJPRUU1TkRWRk5VUXpSVFJGUXpFM1FUb3hNemcxTWpFME5Ua3lMamMzTlRRNlpHWTBZV00wTUdVNU16ZzJObVZqTkdFNU9HSXdaVEptT0dGaE5XUmhaREUzTUdVd09UUTJaZz09IiwicmVnIl0=';
$queryArray = parse_url($url);
the stream argument will be contained within
$queryArray['query'];
This will be an array if there is more than one argument
var_dump($queryArray);
To see all its options
See here php parse_url
Working Example
<?php
$url = 'www.example.com';
$url .='/get_file.php?stream=WyJPRUU1TkRWRk5VUXpSVFJGUXpFM1FUb3hNemcxTWpFME5Ua3lMamMzTlRRNlpHWTBZV00wTUdVNU16ZzJObVZqTkdFNU9HSXdaVEptT0dGaE5XUmhaREUzTUdVd09UUTJaZz09IiwicmVnIl0=';
$queryArray = parse_url($url);
echo $queryArray['query']."<br>"."<br>"."<br>";
var_dump($queryArray);
?>
will return
stream=WyJPRUU1TkRWRk5VUXpSVFJGUXpFM1FUb3hNemcxTWpFME5Ua3lMamMzTlRRNlpHWTBZV00wTUdVNU16ZzJObVZqTkdFNU9HSXdaVEptT0dGaE5XUmhaREUzTUdVd09UUTJaZz09IiwicmVnIl0=
array(2) { ["path"]=> string(28) "www.example.com/get_file.php" ["query"]=> string(155) "stream=WyJPRUU1TkRWRk5VUXpSVFJGUXpFM1FUb3hNemcxTWpFME5Ua3lMamMzTlRRNlpHWTBZV00wTUdVNU16ZzJObVZqTkdFNU9HSXdaVEptT0dGaE5XUmhaREUzTUdVd09UUTJaZz09IiwicmVnIl0=" }
You could try preg_match:
$found = preg_match("/stream=(.+)'/", $html, $match);
if ( $found ) {
echo $match[1];
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.