使用PHP从其他网站获取描述

时间:2013-12-17 19:11:25

标签: php preg-match

我正试图抓住这个使用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,我已经抓住了其他一些数据,只需要帮助这部分。

由于

1 个答案:

答案 0 :(得分:3)

您需要s modifier匹配多行:

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

Demo.