Simple Spider¶
- class kingfisher_scrapy.base_spiders.simple_spider.SimpleSpider(*args, **kwargs)[source]¶
Most spiders can inherit from this class.
It assumes all responses have the same data type.
Inherit from
SimpleSpiderSet a
data_typeclass attribute to the data type of the responsesWrite a
start()method (and any intermediate callbacks) to send requests
import scrapy from kingfisher_scrapy.base_spiders import SimpleSpider class MySpider(SimpleSpider): name = 'my_spider' # SimpleSpider data_type = 'release_package' async def start(self): yield scrapy.Request('https://example.com/api/package.json', meta={'file_name': 'all.json'})
- parse(response)[source]¶
Process response, i.e. extract data from it and generate new requests.
This is the default callback: Scrapy uses it for the response to any request that does not define a
callback, such as the requests thatstart()yields by default.Any
cb_kwargsof the request are passed as keyword parameters.Spiders must define this method, unless every request that they send defines a callback.
See Callback output about the supported return values.