检测网站上的Flash内容

时间:2014-02-28 09:35:24

标签: php flash function

我正在尝试创建一个功能,检查用户是否在网站上有闪存。 到目前为止,我有这个:

$html = file_get_contents('http://www.test.com'); //users website
if(preg_match(".swf", $html, $matches)) {
    print("<pre>"); 
    print_r($matches); 
    print("</pre>");
}

但我没有得到任何结果。 有人有想法吗? :)

2 个答案:

答案 0 :(得分:3)

<?php
$html = file_get_contents('http://www.disneylandparis.nl/'); //users website
$subject = $html;
$pattern = '/.swf/S';
preg_match($pattern, substr($subject,3), $matches);
print_r($matches);

Ruub,正如Shankar Damodaran建议调整正则表达式的作品。

答案 1 :(得分:2)

您可以搜索此文本.swf,而不是搜索flashplayer,因为大多数Flash开发人员都会添加此行文本,因为如果客户端浏览器没有安装Flash,他们会使用此URL进行重定向浏览器。因此,您可以在当前情况下依赖此。

这个网址将出现在大多数Flash网站上。

<a href="http://get.adobe.com/flashplayer/?promoid=JZEFT" id="Download_AdobeFlashPlayer">Don't have Flash ? Get Adobe Flash Player Here</a>

<强> EDIT :

改为使用strpos

<?php
$htmlsrc=file_get_contents('http://www.disneylandparis.nl');
if(strpos($htmlsrc,'flashplayer')!==false)
{
    echo "This website uses flash !";
}