簡體   English   中英

從網頁獲取JavaScript數據數組

[英]Getting JavaScript data arrays from webpage

確定,因此此網頁的功能有所不同。 它使用文本文件並將數據加載到JavaScript中,然后在JavaScript中顯示。 我嘗試使用PHP方法,但無法獲取。

我如何從http://queville.com/cgi-bin/forums/index.cgi獲取S個玩家歷史得分?a = scores&b =總體

就像,如果您查看源代碼,您將在<script> </script>標記之間看到它:

 S[na]="|Daminion|442776|30436|125645|90728|40835|79058|16318|15927|43700|129|0|"; na++; 
 S[na]="|superfly|442490|32398|32032|161903|93689|75086|20018|11020|15937|407|0|"; na++; 
 S[na]="|GodessCrystal|435702|46422|41721|95881|43717|105026|23324|23500|30296|25815|0|"; na++; 
 S[na]="|grandkool|432065|110849|34644|12438|7706|165145|60924|12436|23446|4477|87|"; na++;

我試過使用PHP的file_get_contents類的方法,但是它不起作用...

為我工作:

$x = file_get_contents("http://queville.com/cgi-bin/forums/index.cgi?a=scores&b=Overall");
preg_match_all("/S\[na\]=.+/", $x, $matches);
print_r($matches);

輸出:

Array
(
    [0] => S[na]="|popatop|7210055|1040749|495318|1691275|958880|1084535|401043|535678|163810|838767|1399|"; na++; 
    [1] => S[na]="|SusieQ|6102424|1047948|484290|934258|613093|1222478|344052|515099|109392|831814|253|"; na++;
    // lots more
)

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM