Ask a regular question so write what's wrong with the match
$str = file_get_contents ("http://mil.news.sina.com.cn");
Military hotspot
$reg = ' # ' military hotspot '. * (. *) "#iUs";
Preg_match_all ($reg, $str, $m);
echo "";
Print_r ($m);
?>
Ask for a match link and title so why not? Share to:
------Solution--------------------
$str = file_get_contents ("http://mil.news.sina.com.cn");
Military hotspot
$reg = ' # ' military hotspot. +?href= (\s+) #is ';
Preg_match_all ($reg, $str, $m);
Print_r ($m);
Array
(
[0] = = Array
(
[0] + "military hotspot")
[1] = = Array
(
[0] = Http://blog.sina.com.cn/s/blog_69710d610101fglf.html?tj=1
)
)
------Solution--------------------
Reference:
echo "";
?>
I tried to write it this way, and it's not right.
Its connection does not include quotation marks
$reg = ' # (? <= "Military hotspot"). * (. +) (= famous column) #isU ';
------Solution--------------------
$s _html = file_get_contents ("http://mil.news.sina.com.cn");
$s _html = iconv (' GBK ', ' utf-8 ', $s _html);
$s _gd_reg = ' # ' military hotspot ' (. *) #iUs ';
$a _gd_match = Array ();
Preg_match_all ($s _gd_reg, $s _html, $a _gd_match);