# -*- coding: utf-8 -*-
# Define here the models for your spider middleware
#
# See documentation in:
# https://doc.scrapy.org/en/latest/topics/spider-middleware.html
from scrapy import signals
class BookSpiderMiddleware(object):
# Not all methods need to be defined. If a method is not defined,
# scrapy acts as if the spider middleware does not modify the
# passed objects.
@classmethod
def from_crawler(cls, crawler):
# This method is used by Scrapy to create your spiders.
s = cls()
crawler.signals.connect(s.spider_opened, signal=signals.spider_opened)
return s
def process_spider_input(self, response, spider):
# Called for each response that goes through the spider
# middleware and into the spider.
# Should return None or raise an exception.
return None
def process_spider_output(self, response, result, spider):
# Called with the results returned from the Spider, after
# it has processed the response.
# Must return an iterable of Request, dict or Item objects.
for i in result:
yield i
def process_spider_exception(self, response, exception, spider):
# Called when a spider or process_spider_input() method
# (from other spider middleware) raises an exception.
# Should return either None or an iterable of Response, dict
# or Item objects.
pass
def process_start_requests(self, start_requests, spider):
# Called with the start requests of the spider, and works
# similarly to the process_spider_output() method, except
# that it doesn’t have a response associated.
# Must return only requests (not items).
for r in start_requests:
yield r
def spider_opened(self, spider):
spider.logger.info('Spider opened: %s' % spider.name)
class BookDownloaderMiddleware(object):
# Not all methods need to be defined. If a method is not defined,
# scrapy acts as if the downloader middleware does not modify the
# passed objects.
@classmethod
def from_crawler(cls, crawler):
# This method is used by Scrapy to create your spiders.
s = cls()
crawler.signals.connect(s.spider_opened, signal=signals.spider_opened)
return s
def process_request(self, request, spider):
# Called for each request that goes through the downloader
# middleware.
# Must either:
# - return None: continue processing this request
# - or return a Response object
# - or return a Request object
# - or raise IgnoreRequest: process_exception() methods of
# installed downloader middleware will be called
return None
def process_response(self, request, response, spider):
# Called with the response returned from the downloader.
# Must either;
# - return a Response object
# - return a Request object
# - or raise IgnoreRequest
return response
def process_exception(self, request, exception, spider):
# Called when a download handler or a process_request()
# (from other downloader middleware) raises an exception.
# Must either:
# - return None: continue processing this exception
# - return a Response object: stops process_exception() chain
# - return a Request object: stops process_exception() chain
pass
def spider_opened(self, spider):
spider.logger.info('Spider opened: %s' % spider.name)

manylinux
- 粉丝: 5042
最新资源
- 数学建模与运筹优化_遗传算法_仿真模拟_LaTeX排版_git版本控制_列车时刻表优化_2023年第十三届MathorCup高校数学建模挑战赛B题参赛论文工程文件_通过遗传算法和仿.zip
- 物流配送优化_遗传算法蚁群算法多目标优化Vue-CLIDjango框架_智能路径规划实时调度动态权重调整成本效益分析碳排放计算配送时效评估_面向电商物流与同城配送.zip
- 物流优化_遗传算法_车辆路径规划_华为配送竞赛解决方案_基于遗传算法的多车辆配送路径优化系统_用于解决华为2021年配送优化竞赛中的多车辆路径规划问题_通过个体编码_变异_交叉和选.zip
- 医疗健康管理_遗传算法_局部搜索_单种群遗传算法_多种群遗传算法_仿真优化_序优化_最优计算量分配_体检顾客调度_预约系统优化_基于元启发式算法的体检机构顾客预约与顺序调度研究_两.zip
- 医学影像处理_遗传算法_XFDTD电磁仿真_二维乳腺肿瘤建模_共焦成像_轮廓提取优化_多线程并行计算_基于遗传算法的乳腺肿瘤轮廓自动提取与优化系统研究_用于在XFDTD软件中建立高.zip
- 优化算法_遗传算法_粒子群优化_混合智能优化_参数优化_全局搜索_局部收敛_速度更新_位置更新_交叉变异_适应度计算_种群初始化_最优解更新_多维数据_边界约束_权重调整_迭代优化.zip
- 优化算法与组合数学_遗传算法GA_模拟退火算法SA_多局部解全局优化_旅行商问题TSP求解_智能优化算法实现与比较_用于解决复杂非线性优化问题_提供多种启发式算法选择_包含详细算法.zip
- 智能优化算法_遗传算法与量子计算_基于C实现的遗传算法工具箱_包含TSP问题求解多元函数优化BP神经网络训练量子遗传算法和粒子群优化等多种智能算法实现参考智能算法30.zip
- 智能优化算法_元启发式算法_麻雀优化算法_鲸鱼优化算法_正余弦优化算法_北方苍鹰优化算法_遗传算法_粒子群优化算法_灰狼优化算法_蜻蜓优化算法_蝗虫优化算法_多元宇宙优化算法_多目.zip
- 智能交通系统_遗传算法优化与非支配排序多目标进化计算_基于基本遗传算法和NSGAII的电动汽车充电站调度策略_用于解决大规模电动汽车充电需求下的充电桩资源分配与调度问题优化充电等.zip
- 深度学习_神经网络图像压缩_率失真特性建模与优化_基于MSE和MS-SSIM的端到端训练框架与Python接口实现_用于高效图像压缩与重建的算法研究与性能评估_支持高分辨率图像处理.zip
- 自动控制_模糊PID控制算法_基于MATLAB的智能控制系统设计与参数优化_用于工业过程控制与机器人运动优化的高性能模糊PID控制器仿真平台及参数整定工具包_包含传统PID控制模.zip
- 组合优化算法_遗传算法与动态规划混合优化_多约束条件下高维背包问题求解与性能分析_用于解决资源分配与投资组合优化等实际问题的开源工具包包含完整算法实现可视化分析模块与基准测试框.zip
- afantasyz_Dynamic-traffic-network-loading-model_29992_1752554039501.zip
- chen622_Louvre_7112_1752553971904.zip
- Nanguage_Cellular-Automaton_7112_1752554037446.zip
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈


