From the previous lesson, use fetch()
and get the response
fetch('https://books.toscrape.com/')
response
Inspect the page and find the element containing the books,
https://books.toscrape.com/ and use the shell to find the elemenet
to place into the script
The book is within an <article>
element with a class product_pod
,
use the following css select to get all the books. Use .
if class has any spaces
response.css('article.product_pod')
This will return each book on the current page
Use the get()
method to get the first instance of the books
response.css('article.product_pod').get()
Store the books in a variable
books = response.css('aricle:product_pod')
len(books)