SCP06: Improper first match extraction
What it does
Finds uses of getall()[0], [0].getall() and similar with
Selector and SelectorList that can
be replaced get().
Why is this bad?
get() is cleaner and more efficient.
Example
import scrapy
class MySpider(scrapy.Spider):
name = "myspider"
def parse(self, response):
yield {"title": response.css("h1::text").getall()[0]}
Use instead:
import scrapy
class MySpider(scrapy.Spider):
name = "myspider"
def parse(self, response):
yield {"title": response.css("h1::text").get()}