使用PHP Simple HTML DOM解析器在javascript标记内查找文本 [英] Find text inside javascript tag using PHP Simple HTML DOM Parser
问题描述
我正在尝试在javascript标签内定期查找文本更改:
I'm trying to find a text change regularly inside javascript tag :
<script type="text/javascript">
jwplayer("mediaplayer").setup({
flashplayer: "player.swf",
file:"filename",
provider: "rtmp",
streamer:"rtmp://192.168.1.1/file?wmsAuthSign=RANDOM-114-Character==",
height:500,
width:500,
});
</script>
如何使用PHP Simple HTML DOM解析器获取RANDOM-114-字符(或"streamer" flashvars的全部值),我只是不知道要这样做.
How to get RANDOM-114-Character (or full value of 'streamer' flashvars) using PHP Simple HTML DOM Parser, I just have no idea to do this.
推荐答案
您可以使用正则表达式:
You can do it with regular expression:
preg_match($ pattern,$ java_script,$ matches);
preg_match ($pattern, $java_script, $matches);
模式取决于变量'wmsAuthSign'是否唯一.例如:
Pattern depends, if the variable 'wmsAuthSign' is unique. For example:
$ pattern ='/wmsAuthSign =(.*?)==/';
$pattern = '/wmsAuthSign=(.*?)==/';
preg_match($ pattern,$ java_script,$ matches);
preg_match ($pattern, $java_script, $matches);
echo $ matches [1];
echo $matches[1];
但是您总是可以从'streamer'启动模式,例如'wmsAuthSign'不是唯一的.
But you can always start your pattern from 'streamer' for example if 'wmsAuthSign' is not unique.
这篇关于使用PHP Simple HTML DOM解析器在javascript标记内查找文本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!