aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorlolcat <will@lolcat.ca>2026-07-05 01:57:56 -0400
committerPinapelz <yukais@pinapelz.com>2026-07-06 21:32:18 -0700
commitd69c3170795b02ec7aca7317a7fe64cd76a9c76b (patch)
tree1306faf65450a29af0e0e50c43543f00c432238b
parentd075661645705819d85f6ae7cfd7549194c6a348 (diff)
i overengineered the fuck out of that baidu scraper jesus
-rw-r--r--scraper/baidu.php38
1 files changed, 26 insertions, 12 deletions
diff --git a/scraper/baidu.php b/scraper/baidu.php
index efb14ca..b81c224 100644
--- a/scraper/baidu.php
+++ b/scraper/baidu.php
@@ -666,14 +666,24 @@ class baidu{
//
// Don't parse as a search result if it's a card
//
- $card =
+ $tpl_probe =
$this->fuckhtml
- ->getElementsByClassName(
- "cosc-card",
- $div
+ ->getElementsByAttributeValue(
+ "tpl",
+ "www_index",
+ [$datafield]
);
- if(count($card) !== 0){
+ if(
+ count($tpl_probe) === 0 &&
+ count(
+ $this->fuckhtml
+ ->getElementsByClassName(
+ "cosc-card",
+ $div
+ )
+ ) !== 0
+ ){
//
// Parse chinese youtube shorts
@@ -870,10 +880,13 @@ class baidu{
// class:FYB_RD -> News garbage, IGNORE
$result =
- $this->fuckhtml
- ->getElementsByClassName(
- "result",
- [$datafield]
+ array_merge(
+ $tpl_probe,
+ $this->fuckhtml
+ ->getElementsByClassName(
+ "result",
+ [$datafield]
+ )
);
if(count($result) !== 0){
@@ -885,7 +898,7 @@ class baidu{
$title =
$this->fuckhtml
->getElementsByClassName(
- "sc-link",
+ "cosc-title-a",
"a"
);
@@ -905,8 +918,9 @@ class baidu{
$description =
$this->fuckhtml
- ->getElementsByClassName(
- "c-color",
+ ->getElementsByAttributeValue(
+ "data-sanssr-cmpt",
+ "card/www-summary-1",
$div
);
send patches to the email below
yukais@pinapelz.com
include the subject [PATCH repo_name]
pinapelz.com
homepage