From d55466148541e11b9e997866906b6b9e1088536c Mon Sep 17 00:00:00 2001 From: liuyuhang Date: Thu, 11 Jul 2024 17:16:04 +0800 Subject: [PATCH] =?UTF-8?q?=E2=9C=A8=20feat(command):=20=E8=AE=A2=E5=8D=95?= =?UTF-8?q?=E7=88=AC=E8=99=AB=E7=BB=9F=E8=AE=A1=E8=AF=B7=E6=B1=82=E6=AC=A1?= =?UTF-8?q?=E6=95=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 订单爬虫统计请求次数 --- service/app/server/Douyin.php | 6 ++++++ service/app/server/Meituan.php | 7 +++++++ 2 files changed, 13 insertions(+) diff --git a/service/app/server/Douyin.php b/service/app/server/Douyin.php index 842d5e13..a0ad85cd 100644 --- a/service/app/server/Douyin.php +++ b/service/app/server/Douyin.php @@ -479,6 +479,12 @@ class Douyin public function _curl($url, $params, $method = 'GET') { + // 请求次数统计 + $key = sprintf("Douyin:ReqiestCount:%s", date('Y-m-d')); + $requestCount = Redis::incrBy($key, 1); + if ($requestCount == 1) { + Redis::expire($key, 604800); // 7天 + } $http = $this->gate . $url; if ($method == 'GET') { diff --git a/service/app/server/Meituan.php b/service/app/server/Meituan.php index b86e6111..1739dae6 100644 --- a/service/app/server/Meituan.php +++ b/service/app/server/Meituan.php @@ -119,6 +119,13 @@ class Meituan { public function _curl($url, $params, $method = 'GET') { + // 请求次数统计 + $key = sprintf("Meituan:ReqiestCount:%s", date('Y-m-d')); + $requestCount = Redis::incrBy($key, 1); + if ($requestCount == 1) { + Redis::expire($key, 604800); // 7天 + } + $http = $this->gate.$url; if($method == 'GET') { $http = $http.'?'. http_build_query($params);