0

我正在寻找一种方法来获取游戏通行证和 psnow 当前可用的游戏列表。

在谷歌上找不到它,但也许这里有人有东西?最好的方法是使用 API。

太感谢了 !

4

1 回答 1

1

我刚刚为 PSNow 做了这个,明天在 gamepass 脚本上工作,但是如果有人需要,可以使用这个简单的 PHP 脚本获得 PSNow 游戏列表:

$html = file_get_contents('https://www.playstation.com/fr-fr/ps-now/ps-now-games/#all-ps-now-games');
$doc = new DOMDocument();
$doc->formatOutput = true;
$content_utf = mb_convert_encoding($html, 'HTML-ENTITIES', 'UTF-8'); // correct parsing of utf-8 chars
$doc->loadHTML($content_utf);

$divs = $doc->getElementsByTagName('div');

$psnowgames = [];
foreach($divs as $div) {
    
// POUR LES JEUX LETTRE A
if ($div->getAttribute('id') === 'tab-content-1') {
    $p = $div->getElementsByTagName('p');
    foreach($p as $paragraphe) {
        if($paragraphe->nodeValue == 'PS3' || $paragraphe->nodeValue == 'PS4' || strlen($paragraphe->nodeValue) < 3 ) {} 
        else {
            $psnowgames[] = $paragraphe->nodeValue;
        }
    }
}

// POUR LES JEUX AVEC UNE AUTRE LETTRE
if ($div->getAttribute('role') === 'tabpanel' && $div->getAttribute('id') != 'tab-content-1') {
    $p = $div->getElementsByTagName('p');
    foreach($p as $paragraphe) {
        if($paragraphe->nodeValue == 'PS3' || $paragraphe->nodeValue == 'PS4' || strlen($paragraphe->nodeValue) < 3 ) {} 
        else {
            foreach($paragraphe->childNodes as $child){
                if( strlen($child->nodeValue) < 3 ) {} 
                else {
                    $psnowgames[] = $child->textContent;
                }
            }
        }
    }
}
}

var_dump($psnowgames);

用 $psnowgames 数组做你想做的事 :)

于 2021-03-03T21:50:49.987 回答