简体   繁体   English

使用HTML DOM PARSER和HTML解析Javascript

[英]Parsing Javascript withing Html using HTML DOM PARSER

currently trying to parse the download link for zippyshare files in php the issue is I need to get their javascript and I am not being able to do it. 当前正在尝试解析php中zippyshare文件的下载链接,问题是我需要获取其javascript,但我无法做到这一点。 This is the part of the page I need to parse: 这是我需要解析的页面的一部分:

<script type="text/javascript">
   var somdfunction = function() {
       var a = 327030;
       document.getElementById('dlbutton').omg = 327033%78956;
       var b = parseInt(document.getElementById('dlbutton').omg) * (327033%3);
       var e = function() {if (false) {return a+b+c} else {return (a+3)%b + 3}};
       document.getElementById('dlbutton').href    = "/d/91667079/"+(b+18)+"/Animals%20%28Radio%20Edit%29-www.manomuzika.net.mp3";
       if (document.getElementById('fimage')) {
           document.getElementById('fimage').href  = "/i/91667079/"+(b+18)+"/Animals%20%28Radio%20Edit%29-www.manomuzika.net.mp3";
       }
       var result = 0;
   }
</script>

Which being fetched from its website using: 通过以下方式从其网站获取:

$html = file_get_html($url);

Basically they create the download links dynamically using javascript, I am able to get the source using my parser but I need to cut it down to getting the values of: 基本上,他们使用javascript动态创建下载链接,我能够使用解析器获取源,但是我需要将其缩减为获取以下值:

var a = 327030;
document.getElementById('dlbutton').omg = 327033%78956;

and finally 最后

document.getElementById('dlbutton').href = "/d/91667079/"+(b+18)+"/Animals%20%28Radio%20Edit%29-www.manomuzika.net.mp3";

Once I am able to get these three variables from within the source I will be able to create the download link my issue at the moment is cutting it down to that. 一旦我能够从源代码中获取这三个变量,就可以创建下载链接,目前我的问题正在减少。

I am using this parser: http://simplehtmldom.sourceforge.net/ 我正在使用此解析器: http : //simplehtmldom.sourceforge.net/

If you would like to see the source code I am able to parse at the moment here it is: 如果您想查看源代码,现在可以在此处进行解析:

http://www.somf.us/music/test.php?url=http://www66.zippyshare.com/v/91667079/file.html http://www.somf.us/music/test.php?url=http://www66.zippyshare.com/v/91667079/file.html

You need to use regex because simple is not a javascript parser. 您需要使用正则表达式,因为simple不是JavaScript解析器。 Here's a hint to get you started: 这是一个入门的提示:

preg_match('/var a = (\d+);/', file_get_contents($url), $m);
echo $m[1];

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM