【问题标题】:grab a div value using php curl or file_get_content使用 php curl 或 file_get_content 获取 div 值
【发布时间】:2014-11-18 06:42:39
【问题描述】:
<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_content 获取这个 c864c7cf605d 值,我该怎么做?

【问题讨论】:

  • 我该怎么做?...通过努力并向我们展示您尝试过的方法以及失败的原因。我建议阅读 domdocumentxpath 这是你想要的

标签: php curl file-get-contents


【解决方案1】:

这里有一些代码可以帮助您入门:

<?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

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2018-06-09
    • 2014-01-01
    • 2014-11-13
    • 1970-01-01
    • 2016-12-17
    • 2011-02-10
    • 1970-01-01
    相关资源
    最近更新 更多