我只是想知道为什么这对我不起作用。我想要做的是去掉 m4v 文件。我有一个类似的脚本用于我网站上的图像,它将剥离图像,上传到目录和数据库并链接。但我不能让它以同样的方式工作。感谢您的帮助
<?php
include('simple_html_dom.php');
$html = file_get_html("http://www.mysitesvids.com/m/videos/view/36821");
$element = $html->find("file:");
$result = $element->innertext;
?>
这是网站的代码
<script type="text/javascript" language="javascript">
jwplayer ('embedFlashPlayer').setup ({flashplayer:'/swf/jwplayer5.swf',id:'moviePlayer',width:602,height:404,
file:'http://davesvideos.mysitevids.com/media/b0e9ec18eb567ce41dce906cee7e1c9f/4fcbb164/videos/m/634276.m4v',
image:'/media/80eb2eaca3c58f002be8ab5bda476e91/4fcbb164/videos/p/64/634276.jpg',
provider:'http',controlbar:'bottom',stretching:'uniform',abouttext:'mysite',aboutlink:'http://www.eroprofile.com/'});
glbUpdViews ('0','634276','0','0');
ajaxActive = false;
cmtLoad ('video', '634276', '', '');
ajaxActive = false;
cmtReply ('video', '634276', '0');
</script>
最佳答案
使用正则表达式会更容易解决:
preg_match( "/file:'(.+?)'/", $html, $matches );
if ( $matches ) {
echo $matches[1];
}
我假设您在页面上没有此字符串模式的其他实例。如果您这样做了,并且您只想匹配 m4v,则可以修改表达式以查找该扩展名:
preg_match( "/file:'(.+?\.m4v)'/", $html, $matches );
if ( $matches ) {
echo $matches[1];
}
关于php - DOM Scrape 不工作 PHP,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10873028/