<code>有一个
$link
=
"url"
,打开后代码如下:
......
<div
class
=
"news_list"
>
<ul>
<li>
<span>2016-06-06</span>
<a href=
"/news!show.action?id=f435345c44e04ec3a5e6ccedca29e061"
>羊山新区2016年14条道路绿化工程招标公告</a>
</li>
<li>
<span>2016-06-06</span>
<a href=
"/news!show.action?id=ad4b065149d94704b3d295287f863b5a"
>平桥区明港镇井庄路口-垃圾处理场-何岗村南路口(K0+000-K4+300)公路改建工程施工招标公告</a>
</li>
<li>
<span>2016-05-31</span>
<a href=
"/news!show.action?id=c3b688ae2ec54fb0880a0f60f7a4f5f0"
>信阳市中心医院羊山分院人防工程监理招标公告</a>
</li>
<li>
<span>2016-05-31</span>
<a href=
"/news!show.action?id=2a7060f3519b40b3aa766dd53f2b00ad"
>信阳市儿童医院病房楼建设项目施工及监理项目招标公告</a>
</li>
</ul>
</div>
<!--分页-->
<div
class
=
"page_num"
>
......
<pre
class
=
"brush:php;toolbar:false"
><code>目标:获得<div
class
=
"news_list"
>......<div
class
=
"page_num"
>中href标签里的内容
"/news!show.action?id=2a7060f3519b40b3aa766dd53f2b00ad"
我写的代码如下:
$htmlContent
=
file_get_contents
(
"$link"
);
$num
=preg_match_all(
"/<div.>.*?(href=\".*?\").*<div.>/is"
,
$htmlContent
,
$array
);
var_dump(
$array
[1]);
目前卡顿的地方:在
<h2>回复内容:</h2>
<pre
class
=
"brush:php;toolbar:false"
><code>有一个
$link
=
"url"
,打开后代码如下:
......
<div
class
=
"news_list"
>
<ul>
<li>
<span>2016-06-06</span>
<a href=
"/news!show.action?id=f435345c44e04ec3a5e6ccedca29e061"
>羊山新区2016年14条道路绿化工程招标公告</a>
</li>
<li>
<span>2016-06-06</span>
<a href=
"/news!show.action?id=ad4b065149d94704b3d295287f863b5a"
>平桥区明港镇井庄路口-垃圾处理场-何岗村南路口(K0+000-K4+300)公路改建工程施工招标公告</a>
</li>
<li>
<span>2016-05-31</span>
<a href=
"/news!show.action?id=c3b688ae2ec54fb0880a0f60f7a4f5f0"
>信阳市中心医院羊山分院人防工程监理招标公告</a>
</li>
<li>
<span>2016-05-31</span>
<a href=
"/news!show.action?id=2a7060f3519b40b3aa766dd53f2b00ad"
>信阳市儿童医院病房楼建设项目施工及监理项目招标公告</a>
</li>
</ul>
</div>
<!--分页-->
<div
class
=
"page_num"
>
......
<pre
class
=
"brush:php;toolbar:false"
><code>目标:获得<div
class
=
"news_list"
>......<div
class
=
"page_num"
>中href标签里的内容
"/news!show.action?id=2a7060f3519b40b3aa766dd53f2b00ad"
我写的代码如下:
$htmlContent
=
file_get_contents
(
"$link"
);
$num
=preg_match_all(
"/<div.>.*?(href=\".*?\").*<div.>/is"
,
$htmlContent
,
$array
);
var_dump(
$array
[1]);
目前卡顿的地方:在
<p
class
=
"answer fmt"
data-id=
"1020000005671716"
>
</p>
<p>环视应该可以满足你现在的需求</p>
<pre
class
=
"brush:php;toolbar:false"
><code
class
=
"php"
>preg_match_all(
'/(?\d{4}-\d{2}-\d{2})(?:.*?href=\")(.*?)(?:\".*?)(?=)/is'
,
$a
,
$matches
);</code>