pass a selector through scrapy itemloader

Solution 1:

Using itemloaders is the correct way. Pass the two selectors in sequence and then use an output processor to join them. The default Itemloader can serve the purpose

from scrapy.loader import ItemLoader
from itemloaders.processors import Join

l = ItemLoader(MyItem(), response=response, selector=response.css('css_to_main'))
l.add_css('variable_name','css_to_one::text')
l.add_css('variable_name','css_to_two::text')
yield l.load_item()

In the item Field, you then process the values using input and output processors. I have omitted the input processor for simplicity. But you can add them as required.

class MyItem(scrapy.Item):
    variable_name = scrapy.Field(output_processor = Join(''))