Go to the profile of  Paras Patidar
Paras Patidar
I am working on Machine Learning, Python and Django.
1 min read

Introduction to the Scrapy Selector

Creating a scrapy selector object using a string with the HTML code Created a scrapy selector object using a string with html code. The Selector sel has selected the entire HTML document.

Creating a scrapy selector object using a string with the HTML code

  1. Created a scrapy selector object using a string with html code.
  2. The Selector sel has selected the entire HTML document.

Selecting selectors

  1. We can use the xpath call within a Selector to create new Selectors of specific.
  2. The return is a SelectorList of Selector objects.

Extract data from a SelectorList

Use the .extract() method.

sel.xpath("//p").extract()

We can use the .extract_first()  method to extract the first element from the list

sel.xpath("//p").extract_first()