Php 如何从preg_match_all获得钥匙?
代码正在运行:Php 如何从preg_match_all获得钥匙?,php,preg-match-all,Php,Preg Match All,代码正在运行: $url = 'http://www.google.com/search?hl=en&tbo=d&site=&source=hp&q=upoznavanje'; $html = file_get_html($url); preg_match_all('/(?<="><cite>).*?(?=<\/cite><div\ class=)/', $html, $output); foreac
$url = 'http://www.google.com/search?hl=en&tbo=d&site=&source=hp&q=upoznavanje';
$html = file_get_html($url);
preg_match_all('/(?<="><cite>).*?(?=<\/cite><div\ class=)/', $html, $output);
foreach ($output[0] as $link) {
$link ."<br>" ;
}
我发现了如何在无循环的情况下从数组中提取单个数据:
print_r($output[0][0]);
这可能会重复5分钟左右,因为谷歌真的很擅长阻止人们刮取他们的搜索结果。刮器一直工作得很好,当我把它放在foreach中时,我不明白为什么不使用$output[0]$link;这是一条毫无意义的线,因为它实际上什么都不做。另外,你能发布var_dump$output的结果吗;是的,缺少echo,我试图删除所有非点代码,但我想告诉大家foreach是有效的,有varu dump:array1{[0]=>array10{[0]=>string21[1]=>string47[2]=>string39[3]=>string30[4]=>string22 www.prvi-sastanak.net/[5]=>string122 najbolji-sajtovi-za-upoznavanje-i-dejt-foto
print_r($output[0][0]);