2013-12-17 72 views
3

我試圖抓住這個描述,這是在網站上使用preg_match只是有問題:從另一個網站使用PHP獲取描述

這是我試圖抓住。只要繼承人什麼我已經試過<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,我知道了搶奪其他一些數據,就需要這部分的幫助。

感謝

+0

只需使用這樣的功能:http://stackoverflow.com/a/8010000/2100549 – skrilled

+0

你在哪裏設置變量'$ description'? – Barmar

+0

抱歉,現在檢查,是一個錯字。我如何使該功能與從網站獲取數據一起工作? – Exoon

回答

3

您需要s modifier匹配多行:

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

Demo.

+1

非常感謝! – Exoon