04-04 css selectors in scrapy shell

1

Start shell, run fetch to get this html into the response

fetch('https://books.toscrape.com/')

We get a 200 response if it works and it places the html page into a response we can use css selectos on

2

use css selectors on response

response.css('article.product_pod')

3

Adding the get() method , gets the first article.product_pod, (to me, akin to querySelector() js )

response.css('article.product_pod').get()

4

Put results in variables

books = response.css('article.product_pod')

You can check by running len() as well

And you can get first book

book = books[0]

or (maybe) it's a little different, has more html, as you can see in the screenshot

book =response.css('article.product_pod').get()