时间:2021-07-01 10:21:17 帮助过:34人阅读
$c1 = "/\s*(?:.*)<\/a>\s*<\/h3>/Uis"; $content= get_content('http://www.so.com/s?q=csdn&pn=7&j=0'); preg_match_all($c1,$content,$arr1); print_r($arr1);
你应该重新考虑一下问问题的方法,这样问没几个人愿意回答的
全文都找不到一个
用惯了DOM解析,正则生疏了,那个href太长了,所有用了2次preg_match_all,勉强匹配出来了。
$urls = 'http://www.so.com/s?q=csdn&pn=7&j=0';$ch = curl_init();curl_setopt($ch, CURLOPT_URL,$urls);curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);$content = curl_exec($ch);curl_close($ch);$c1 = "/