mirror of
https://git.lolcat.ca/lolcat/4get.git
synced 2024-12-03 23:42:16 -05:00
brave fix
This commit is contained in:
parent
9c18753ec3
commit
070f9d442b
2 changed files with 41 additions and 3 deletions
|
@ -381,6 +381,8 @@ class fuckhtml{
|
|||
$json_out = null;
|
||||
$last_char = null;
|
||||
|
||||
$keyword_check = null;
|
||||
|
||||
for($i=0; $i<strlen($json); $i++){
|
||||
|
||||
switch($json[$i]){
|
||||
|
@ -396,6 +398,7 @@ class fuckhtml{
|
|||
|
||||
$bracket = false;
|
||||
$is_close_bracket = true;
|
||||
|
||||
}else{
|
||||
|
||||
if($bracket === false){
|
||||
|
@ -429,6 +432,31 @@ class fuckhtml{
|
|||
$is_close_bracket === false
|
||||
){
|
||||
|
||||
// do keyword check
|
||||
$keyword_check .= $json[$i];
|
||||
|
||||
if(in_array($json[$i], [":", "{"])){
|
||||
|
||||
$keyword_check = substr($keyword_check, 0, -1);
|
||||
|
||||
if(
|
||||
preg_match(
|
||||
'/function|array|return/i',
|
||||
$keyword_check
|
||||
)
|
||||
){
|
||||
|
||||
$json_out =
|
||||
preg_replace(
|
||||
'/[{"]*' . preg_quote($keyword_check, "/") . '$/',
|
||||
"",
|
||||
$json_out
|
||||
);
|
||||
}
|
||||
|
||||
$keyword_check = null;
|
||||
}
|
||||
|
||||
// here we know we're not iterating over a quoted string
|
||||
switch($json[$i]){
|
||||
|
||||
|
|
|
@ -293,8 +293,8 @@ class brave{
|
|||
/*
|
||||
$handle = fopen("scraper/brave.html", "r");
|
||||
$html = fread($handle, filesize("scraper/brave.html"));
|
||||
fclose($handle);
|
||||
*/
|
||||
fclose($handle);*/
|
||||
|
||||
|
||||
try{
|
||||
$html =
|
||||
|
@ -410,10 +410,20 @@ class brave{
|
|||
throw new Exception("Could not grep JavaScript object");
|
||||
}
|
||||
|
||||
$data =
|
||||
rtrim(
|
||||
preg_replace(
|
||||
'/\(Array\(0\)\)\).*$/',
|
||||
"",
|
||||
$grep[1]
|
||||
),
|
||||
" ]"
|
||||
) . "]";
|
||||
|
||||
$data =
|
||||
$this->fuckhtml
|
||||
->parseJsObject(
|
||||
$grep[1]
|
||||
$data
|
||||
);
|
||||
unset($grep);
|
||||
|
||||
|
|
Loading…
Reference in a new issue