本段代码是正则获取内容中的所有连接地址,这个在采集的时候经常用到
$con= file_get_contents($url);
$pattern = '/<a(?:.*?)href="(((?:http(?:s?):\/\/)?([^\"\/]+))?(?:[^\"]*))"(?:[^>]*?)>([^<]*?)<\/a>/i';
preg_match_all($pattern, $con, $links);
$links = array_flip(array_flip($links[1]));
来源:http://www.3qphp.com/php/phpjch/2069.html
如果文章或资源对您有帮助,欢迎打赏作者。一路走来,感谢有您!
txttool.com 说一段 esp56物联 查询128 IP查询