MCPcopy
hub / github.com/scrapy/scrapy / item_scraped

Method item_scraped

scrapy/extensions/feedexport.py:612–645  ·  view source on GitHub ↗
(self, item: Any, spider: Spider)

Source from the content-addressed store, hash-verified

610 )
611
612 def item_scraped(self, item: Any, spider: Spider) -> None:
613 slots = []
614 for slot in self.slots:
615 if not slot.filter.accepts(item):
616 slots.append(
617 slot
618 ) # if slot doesn't accept item, continue with next slot
619 continue
620
621 slot.start_exporting()
622 assert slot.exporter
623 slot.exporter.export_item(item)
624 slot.itemcount += 1
625 # create new slot for each slot with itemcount == FEED_EXPORT_BATCH_ITEM_COUNT and close the old one
626 if (
627 self.feeds[slot.uri_template]["batch_item_count"]
628 and slot.itemcount >= self.feeds[slot.uri_template]["batch_item_count"]
629 ):
630 uri_params = self._get_uri_params(
631 spider, self.feeds[slot.uri_template]["uri_params"], slot
632 )
633 self._pending_close_coros.append(self._close_slot(slot, spider))
634 slots.append(
635 self._start_new_batch(
636 batch_id=slot.batch_id + 1,
637 uri=slot.uri_template % uri_params,
638 feed_options=self.feeds[slot.uri_template],
639 spider=spider,
640 uri_template=slot.uri_template,
641 )
642 )
643 else:
644 slots.append(slot)
645 self.slots = slots
646
647 def _load_components(self, setting_prefix: str) -> dict[str, Any]:
648 conf = without_none_values(

Callers

nothing calls this directly

Calls 6

_get_uri_paramsMethod · 0.95
_close_slotMethod · 0.95
_start_new_batchMethod · 0.95
acceptsMethod · 0.45
start_exportingMethod · 0.45
export_itemMethod · 0.45

Tested by

no test coverage detected