this time I'm looking for something really special. In my PHP page, I got a table generated by a Javascript, here is the example :

这次我正在寻找一些非常特别的东西。在我的PHP页面中,我得到了一个由Javascript生成的表,这是示例:

Example Page

示例页面

This table is racing game results. I didn't write the JS, and I can't change the format of the results. What I need is to parse these results to get variables, to generate championship results giving points to guys, adding points of multiple series, etc...

此表是赛车游戏结果。我没有写JS,我无法改变结果的格式。我需要的是解析这些结果以获得变量,生成锦标赛结果给人们点数,添加多个系列的点等等......

I tried :

我试过了 :

  • Parsing with DOMDocument, also substr, but as it's JS generated it can't work.

    解析DOMDocument,也是substr,但是因为它生成的JS它无法工作。

  • >>this solution<< which sounded good but it doesn't work.

    >>这个解决方案< <听起来不错,但不起作用。< p>

Do you guys have any idea to get an exploitable array ? If not, what do you suggest as alternative solution ? I'm not able to reproduce the JS in a PHP function, too hard.

你们有什么想法获得可开发的阵列吗?如果没有,您建议作为替代解决方案?我无法在PHP函数中重现JS,太难了。

Here is the JS : click Thank you !

这是JS:点击谢谢!

1 个解决方案

#1


1

Here's how you'd be able to parse the initial array in PHP:

以下是如何在PHP中解析初始数组:

$url = 'http://mxs-concept.com/liveresults/test.php';
$page = file_get_contents($url); // fetch the page

preg_match('/resultslines=(.+)print_race_analysis/sim', $page, $matches); // find javascript array
$js = preg_replace('/,\s+\]$/', ']', $matches[1]); // fix last comma before "]"

$array = json_decode($js); // decode the array
var_dump($array); // see the exact array you had in javascript

However, after reading your edit, it seems that you'd need more work if you're taking the PHP way. You might want to try to install NodeJS and make it parse the JS but might be an overkill. If I would you, I'd translate the JS to PHP even if it will take a day just because NodeJS might take a week instead.

但是,在阅读完编辑后,如果您采用PHP方式,似乎需要更多工作。您可能想要尝试安装NodeJS并使其解析JS但可能是一种矫枉过正。如果我愿意,我会将JS翻译成PHP,即使它需要一天,因为NodeJS可能需要一周时间。

更多相关文章

  1. mysql锁机制之示例讲解
  2. mysql主从同步报slave_sql_running:no的解决方案
  3. win7下Django的MySql安装,问题解决方案
  4. mysql 事物没提交导致事物一直运行解决方案
  5. 无法连接远程MySQL数据库的解决方案
  6. MySQL 示例数据库sakila
  7. [征集] MySQL交叉表解决方案及散分
  8. MySQL官网示例数据库emploees分析使用
  9. PHP MYSQL 出现中文乱码的解决方案

随机推荐

  1. JVM 故障处理工具列表
  2. Object对象你真理解了吗?
  3. MyBatis 如何编写一个自定义插件?运行原理
  4. 请查收,32 道 MyBatis 的高频面试题已答完
  5. 聊聊我是怎么开发Java面试题小程序的
  6. Class 文件的结构
  7. 图解 Class 文件结构
  8. 《深入理解 Java 虚拟机·第三版》读书笔
  9. 常见 JVM dump 指令整理
  10. 抽点时间写篇文章都是享受