aboutsummaryrefslogtreecommitdiffstats
path: root/scraper/sc.php
diff options
context:
space:
mode:
authorlolcat <will@lolcat.ca>2025-12-13 20:03:23 -0500
committerlolcat <will@lolcat.ca>2025-12-13 20:03:23 -0500
commitfd155b192e507752f4c6268547f7a81fb09986b8 (patch)
treec886f8a46fa4e53c9978e23883b7adf4d68dfc32 /scraper/sc.php
parent800cde93cf94068138320994c8bfbf03af4b6400 (diff)
cloudfront ratelimit handler
Diffstat (limited to 'scraper/sc.php')
-rw-r--r--scraper/sc.php21
1 files changed, 20 insertions, 1 deletions
diff --git a/scraper/sc.php b/scraper/sc.php
index 004d673..1c6132e 100644
--- a/scraper/sc.php
+++ b/scraper/sc.php
@@ -135,6 +135,8 @@ class sc{
$type = $get["type"];
$proxy = $this->backend->get_ip();
+
+ // token is not tied to an IP address
$token = $this->get_token($proxy);
switch($type){
@@ -247,13 +249,30 @@ class sc{
fclose($handle);
*/
+ $this->fuckhtml->load($json);
+
+ // detect for cloudfront error
+ $title =
+ $this->fuckhtml
+ ->getElementsByTagName(
+ "title"
+ );
+
+ if(
+ count($title) !== 0 &&
+ str_contains($title[0]["innerHTML"], "The request could not be satisfied")
+ ){
+
+ throw new Exception("Ratelimited by Cloudfront, add some working proxies");
+ }
+
$json = json_decode($json, true);
if($json === null){
if($last_attempt === true){
- throw new Exception("Fetched an invalid token (please report!!)");
+ throw new Exception("Fetched an invalid token");
}
// token might've expired, get a new one and re-try search
send patches to the email below
yukais@pinapelz.com
include the subject [PATCH repo_name]
pinapelz.com
homepage