I try to parse a small part of a webpage. As I need to analyse a part of executed JS I can't use a HTML parser. Well, as what I have to find is "easy" I used preg_match()
.
When I validate my code in regex101.com everything seems to be ok and I get what I want. But when I execute my code it does not work correctly.
Example of what I try to parse:
// Setup SoundManager
soundManager.setup({
debugMode: false,
flashLoadTimeout: 1000,
flashVersion: 9,
preferFlash: true,
url: "path/swf/",
useHighPerformance: true,
useHTML5Audio: false,
waitForWindowLoad: false,
onready: function() {
soundManager.createSound({
id: "radio",
serverURL: "rtmp://popradio.stweb.tv:1935/popradio/",
url: [{
type: "audio/mp4",
}],
autoLoad: true,
autoPlay: true,
multiShot: false,
volume: volume,
onconnect: function( bConnect ) {
setButtonStop();
},
onfailure: function() {
setButtonError();
},
onload: function(bSuccess) {
if (bSuccess == true) {
setButtonStop();
} else {
if (window.onloadRetry != 2) {
window.onloadRetry++;
soundManager.reboot();
} else {
setButtonError();
}
}
},
onplay: function() {
setButtonStop();
}
});
},
ontimeout: function() {
setButtonError();
}
});
I just want the value of serverURL so I made :
if (preg_match('#serverURL: "(.*)",#', $html, $rtmp)) {
$streamurl = $rtmp[1] ; ;
echo $streamurl ;
}
But it never ends, it mades me a display of the whole webpage (from ServerUrl: )
What did I make wrong? I read the docs about preg_match()
, but I did not find anything.