aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorlolcat <will@lolcat.ca>2024-10-29 21:29:17 -0400
committerlolcat <will@lolcat.ca>2024-10-29 21:29:17 -0400
commit070f9d442bee7801ce1de3ab4e2c99cb33c9f4b3 (patch)
tree5d05d6219b16db3e0786914f3c5eb90a515e5df6
parent9c18753ec3b19571f7a84865faa090e48b12bc38 (diff)
brave fix
-rw-r--r--lib/fuckhtml.php28
-rw-r--r--scraper/brave.php16
2 files changed, 41 insertions, 3 deletions
diff --git a/lib/fuckhtml.php b/lib/fuckhtml.php
index d89a7bc..ee1353c 100644
--- a/lib/fuckhtml.php
+++ b/lib/fuckhtml.php
@@ -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]){
diff --git a/scraper/brave.php b/scraper/brave.php
index fd4c46e..ee0c37d 100644
--- a/scraper/brave.php
+++ b/scraper/brave.php
@@ -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 =
@@ -411,9 +411,19 @@ class brave{
}
$data =
+ rtrim(
+ preg_replace(
+ '/\(Array\(0\)\)\).*$/',
+ "",
+ $grep[1]
+ ),
+ " ]"
+ ) . "]";
+
+ $data =
$this->fuckhtml
->parseJsObject(
- $grep[1]
+ $data
);
unset($grep);
send patches to the email below
yukais@pinapelz.com
include the subject [PATCH repo_name]
pinapelz.com
homepage