From c94cd5b51b92a052119cf8d19996ddd7f24ca0a7 Mon Sep 17 00:00:00 2001 From: Cyril Mouchel Date: Sun, 17 Feb 2019 20:17:50 +0100 Subject: [PATCH 1/2] Drop few words about getall selector being called To avoid people opening scrapy source code to make sure getall is called over get --- docs/topics/loaders.rst | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/docs/topics/loaders.rst b/docs/topics/loaders.rst index f3b6aa4a1..fd364d340 100644 --- a/docs/topics/loaders.rst +++ b/docs/topics/loaders.rst @@ -31,7 +31,8 @@ using the Item class specified in the :attr:`ItemLoader.default_item_class` attribute. Then, you start collecting values into the Item Loader, typically using -:ref:`Selectors `. You can add more than one value to +:ref:`Selectors `. To note, the Item Loader will extract data +by using the selector ``.getall()`` method. You can add more than one value to the same item field; the Item Loader will know how to "join" those values later using a proper processing function. From 4eed8e2d609bcd1be7ee59cab1a17422b5432381 Mon Sep 17 00:00:00 2001 From: Cyril Mouchel Date: Tue, 19 Feb 2019 21:35:29 +0100 Subject: [PATCH 2/2] Update loaders.rst --- docs/topics/loaders.rst | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/docs/topics/loaders.rst b/docs/topics/loaders.rst index fd364d340..f23f3da60 100644 --- a/docs/topics/loaders.rst +++ b/docs/topics/loaders.rst @@ -65,7 +65,11 @@ data that will be assigned to the ``name`` field later. Afterwards, similar calls are used for ``price`` and ``stock`` fields (the latter using a CSS selector with the :meth:`~ItemLoader.add_css` method), and finally the ``last_update`` field is populated directly with a literal value -(``today``) using a different method: :meth:`~ItemLoader.add_value`. +(``today``) using a different method: :meth:`~ItemLoader.add_value`. To note +:meth:`~ItemLoader.add_css` and :meth:`~ItemLoader.add_xpath` methods will always +return a list as they are actually calling selector ``getall()`` method over +``get()`` which may return a string value. Thus, input processors should be +implemented by waiting for a list instead of a single string. Finally, when all data is collected, the :meth:`ItemLoader.load_item` method is called which actually returns the item populated with the data