使用php curl或file_get_content获取div值

时间:2014-11-18 06:42:40

标签: php curl file-get-contents

<fieldset>
<h2 class="fs-title">Success !</h2>
<h3 class="fs-subtitle">Here is the MAC Address and the Password associated with the User ID provided.</h3>
<div id="wrapper">
<input type="text" id="search" style="text-transform: uppercase;" value="c864c7cf605d" readonly="">
</div>
<div id="wrapper">
<input type="text" id="search" style="height: 55px;" value="123456" readonly="">
</div>
</fieldset>

在这里,我只想使用curl或file_get_contents获取这个c864c7cf605d值,我该怎么做?

1 个答案:

答案 0 :(得分:0)

以下是一些可帮助您入门的代码:

<?php

$content = '
<fieldset>
<h2 class="fs-title">Success !</h2>
<h3 class="fs-subtitle">Here is the MAC Address and the Password associated with the User ID provided.</h3>
<div id="wrapper">
<input type="text" id="search" style="text-transform: uppercase;" value="c864c7cf605d" readonly="">
</div>
<div id="wrapper">
<input type="text" id="search" style="height: 55px;" value="123456" readonly="">
</div>
</fieldset>';

preg_match('/value="(.+?)"/', $content, $result);
echo $result[1];
?>

输出为:c864c7cf605d