美团订单爬虫修改为每次爬取指定天数内的订单,且只爬取10页

This commit is contained in:
liuyuhang 2024-07-09 10:14:09 +08:00
parent f2f1652368
commit 6fa19ce2eb
1 changed files with 19 additions and 9 deletions

View File

@ -180,14 +180,19 @@ class SpiderMt extends Command
// return 1;
// sleep(5);
$time = strtotime(date('Y-m-d'));
for ($i = 0; $i <= $d; $i++) {
$day = $time - $i * 24 * 3600;
$start = date('Y-m-d', $day);
$end = date('Y-m-d 23:59:59', $day);
// $time = strtotime(date('Y-m-d'));
// for ($i = 0; $i <= $d; $i++) {
// $day = $time - $i * 24 * 3600;
// $start = date('Y-m-d', $day);
// $end = date('Y-m-d 23:59:59', $day);
// $this->orders($start, $end, false);
// // $this->_kuaishouOrder($start, $end, false);
// }
$start = date('Y-m-d 00:00:00', strtotime("-{$d} days"));
$end = date('Y-m-d 23:59:59');
$this->orders($start, $end, false);
// $this->_kuaishouOrder($start, $end, false);
}
if (date('H') >= 1 && date('H') <= 7) {
$this->reload($output);
@ -332,7 +337,12 @@ class SpiderMt extends Command
try {
$mei = new Meituan();
$list = $mei->get($page, $start, $end);
$pages = $mei->totalPage;
// $pages = $mei->totalPage;
if ($mei->totalPage === 1) {
$pages = 1;
}
} catch (\Exception $e) {
Log::error(dirname(__FILE__) . __LINE__ . $e);
}