Periodic Spider¶
- class kingfisher_scrapy.base_spiders.periodic_spider.PeriodicSpider(*args, **kwargs)[source]¶
Collect data from an API that accepts a year, year-month, date or datetime as a query string parameter or URL path component.
Inherit from
PeriodicSpider
Set a
date_format
class attribute to “year”, “year-month”, “date” or “datetime”Set a
pattern
class attribute to a URL pattern, with placeholders. If thedate_format
is “year”, then a year is passed to the placeholder as anint
. If thedate_format
is “year-month”, then the first day of the month is passed to the placeholder as adate
, which you can format as, for example:Set a
formatter
class attribute to set the file name like inbuild_request()
Set a
default_from_date
class attribute to a year (“YYYY”) or year-month (“YYYY-MM”)If the source stopped publishing, set a
default_until_date
class attribute to a year or year-monthOptionally, if the
date_format
is “date”, set astep
class attribute to indicate the length of intervals, in days - otherwise, it defaults to 1Optionally, set a
start_requests_callback
class attribute to a method’s name as a string - otherwise, it defaults toparse()
If
sample
is set, the data from the most recent year or month is retrieved.- date_required = True¶
- step = 1¶
- start_requests_callback = 'parse'¶