gpt4 book ai didi

php - 使用 PHP 从另一个网站获取描述

转载 作者:搜寻专家 更新时间:2023-10-31 20:41:26 24 4
gpt4 key购买 nike

我正在尝试使用 preg_match 获取网站上的描述,但有问题:

这就是我想要捕获的。只是 <b>Game Description:</b><br /> 之后的文字最多 <b>Tool v3.1 Info:

<b>Game Description:</b><br />
Steel Diver is a new action-packed submarine combat game from Nintendo that<br />
immerses players in the 3D action with unique game controls and lush 3D<br />
environments. The player can choose from three different submarines, each<br />
with touch-screen control panels that players will have to master to guide<br />
them through treacherous undersea caverns while engaging enemy submarines,<br />
dodging depth charges and battling massive sea creatures. Steel Diver also<br />
takes advantage of the built-in gyroscope of the Nintendo 3DS system. The<br />
combination of 3D game play and one-of-a-kind controls makes for an immersive<br />
combination that must be experienced to be believed.<br />
<br />
<b>Tool v3.1 Info:

这是我尝试过的:

    $pattern1 = '#<b>Game Description:</b><br />\s*(.*?)\s*<b>Tool v3.1 Info:#';
preg_match($pattern1,$downloadPage,$description);
print_r($description);

$downloadPage只是使用 curl 打开 URL,我已经获取了一些其他数据,这部分只需要帮助。

谢谢

最佳答案

您需要 s modifier匹配多行:

$pattern1 = '#<b>Game Description:</b><br />\s*(.*?)\s*<b>Tool v3.1 Info:#s';

Demo.

关于php - 使用 PHP 从另一个网站获取描述,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20642658/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com