只匹配第一个
<a href="javascript:void(0);" id="js_name">禾葡兰</a>
public function get_time(){
$regex="/<a (.*?) id=\"js_name\">(.*?)<\/a>/is";
$return = file_get_contents('https://mp.weixin.qq.com/s/ZX5j3V1W3L6UykSVyfoASg');
preg_match($regex, $return, $matches);
print_r($matches);
}
匹配全部
$regex="/<div class=\"tideTable\"(.*?)>(.*?)<\/div>/ism";
preg_match_all($regex, $return, $matches)
print_r($matches);
//抓取jS里的值
public function get_time(){
$regex='/var ct="(\d+)"/'; //获取ct="",里面的数字
$str = 'var ct="1531288854"*1';
preg_match($regex, $str, $matches);
print_r($matches);
}
版权声明:本文为wbj16116原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。