Created
June 25, 2018 15:05
-
-
Save plonknimbuzz/4b84c692ad4aa054fecfd1ffe2deae5c to your computer and use it in GitHub Desktop.
asdadas
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
private function parseRawData2($str) | |
{ | |
if (preg_match_all( | |
"/<div class=\"result-link\">.+<h3>.+<a href=\"([^\s]*)\".+title=\"(.*)\" class.+>.+<div class=\"excerpt\">(.+)<\/div>/Usi", | |
$str, | |
$m | |
)) { | |
$res = []; | |
foreach ($m[1] as $k => $v) { | |
$res[] = [ | |
"link" => $v, | |
"title" => $m[2][$k], | |
"desc" => str_replace( | |
["\n\n", "\n\n", "<span class=\"result-highlight\">", "</span>", " "], | |
["\n", "\n", "<b>", "</b>", " "], | |
trim($m[3][$k]) | |
) | |
]; | |
} | |
return $res; | |
} else { | |
return []; | |
} | |
} | |
private function parseRawData($str) | |
{ | |
$dom = new Dom; | |
$dom->load($str); | |
$result = $dom->find('.summary'); | |
if(count($result) > 0) | |
{ | |
$res = []; | |
foreach ($result as $row) { | |
$a = $row->find('.result-link h3 a'); | |
$res[] = [ | |
"link" => $a->getAttribute('href'), | |
"title" => $a->getAttribute('title'), | |
"desc" => str_replace( | |
["\n\n", "<span class=\"result-highlight\">", "</span>", " "], | |
["\n", "<b>", "</b>", " "], | |
trim($row->find('.excerpt')->text()) | |
) | |
]; | |
} | |
return $res; | |
} else { | |
return []; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment