美团订单爬虫修改为每次爬取指定天数内的订单,且只爬取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; // return 1;
// sleep(5); // sleep(5);
$time = strtotime(date('Y-m-d'));
for ($i = 0; $i <= $d; $i++) { // $time = strtotime(date('Y-m-d'));
$day = $time - $i * 24 * 3600; // for ($i = 0; $i <= $d; $i++) {
$start = date('Y-m-d', $day); // $day = $time - $i * 24 * 3600;
$end = date('Y-m-d 23:59:59', $day); // $start = date('Y-m-d', $day);
$this->orders($start, $end, false); // $end = date('Y-m-d 23:59:59', $day);
// $this->_kuaishouOrder($start, $end, false); // $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);
if (date('H') >= 1 && date('H') <= 7) { if (date('H') >= 1 && date('H') <= 7) {
$this->reload($output); $this->reload($output);
@ -332,7 +337,12 @@ class SpiderMt extends Command
try { try {
$mei = new Meituan(); $mei = new Meituan();
$list = $mei->get($page, $start, $end); $list = $mei->get($page, $start, $end);
$pages = $mei->totalPage; // $pages = $mei->totalPage;
if ($mei->totalPage === 1) {
$pages = 1;
}
} catch (\Exception $e) { } catch (\Exception $e) {
Log::error(dirname(__FILE__) . __LINE__ . $e); Log::error(dirname(__FILE__) . __LINE__ . $e);
} }