Regex PHP: get specific content from another website -


i'm writing php script fetch specific codes other site.

all done , fetching div has class , showing on page.

$title = '#\<div class="detailbox"\>(.+?)\<\/div\>#s'; preg_match($title, $page, $titles); echo $titles[0]; 

but when try fetch table shows nothing

the content on other site this:

<tr>    <th scope="row">開催時間</th>    <td>10:30~17:00</td> </tr> 

and i'm using code fetch it:

$date = '#\<tr\><th scope="row"\>開催時間<\/th\><td\>(.+?)\<\/td\><\/tr\>#s'; preg_match($date, $page, $dates); echo $dates[0]; 

i have tried $date = '#\<th scope="row"\>開催時間<\/th\>#s'; , works not if add <td> in it.

what i'm doing wrong?

you need turn on unicode modifier u , match inbetween line breaks.

$date = '#<tr>\s*<th scope="row">開催時間</th>\s*<td>(.+?)</td>\s*</tr>#su'; preg_match($date, $page, $dates); 

Comments

Popular posts from this blog

python - No exponential form of the z-axis in matplotlib-3D-plots -

php - Best Light server (Linux + Web server + Database) for Raspberry Pi -

c# - "Newtonsoft.Json.JsonSerializationException unable to find constructor to use for types" error when deserializing class -