Store
存储器贯穿在脚本执行的全过程,帮助你在脚本执行过程中收集和存储信息
实现Store
import crawlipt as cpt
class Store(cpt.StoreBase):
@check
def __init__(self, is_replace: bool = False):
"""
:param is_replace: need replace the value of method or not
"""
self.is_replace = is_replace
self.data = {}
@check
def set(self, method: str, value: Any) -> None:
if method in self.data.keys():
if self.is_replace:
self.data[method] = value
else:
self.data[method].append(value)
return
if self.is_replace:
self.data[method] = value
else:
self.data[method] = [value]内置Store对象
使用Store
最后更新于