'commit'
This commit is contained in:
41
Core/BaseCrawler.py
Normal file
41
Core/BaseCrawler.py
Normal file
@@ -0,0 +1,41 @@
|
||||
# coding=utf-8
|
||||
import abc
|
||||
import logging
|
||||
|
||||
class BaseCrawler(abc.ABC):
|
||||
"""
|
||||
所有小程序爬虫的基类。
|
||||
定义了标准的生命周期方法。
|
||||
"""
|
||||
|
||||
def __init__(self, service=None):
|
||||
self.logger = logging.getLogger(self.__class__.__name__)
|
||||
self.service = service
|
||||
|
||||
@abc.abstractmethod
|
||||
async def start(self):
|
||||
"""
|
||||
启动爬虫的主入口。
|
||||
"""
|
||||
pass
|
||||
|
||||
@abc.abstractmethod
|
||||
async def open_app(self):
|
||||
"""
|
||||
打开目标小程序。
|
||||
"""
|
||||
pass
|
||||
|
||||
@abc.abstractmethod
|
||||
async def crawl_list(self):
|
||||
"""
|
||||
爬取列表页。
|
||||
"""
|
||||
pass
|
||||
|
||||
@abc.abstractmethod
|
||||
async def crawl_detail(self, station_info):
|
||||
"""
|
||||
爬取详情页。
|
||||
"""
|
||||
pass
|
||||
Reference in New Issue
Block a user