In scrapy utilized to extract data Selector

The object is created

  Selector located scrapy.selector achieve class module Selector object created when a document can be passed Html page string constructor method to Selector

2, select the data

  Calls Selector object xpath or css method (incoming xpath or css selector expression), you can select a certain part of the document

  xpath and css method returns a SelectorList objects, each of which comprises a portion corresponding to the selected Selector object, SelectorList list of interfaces supported, for loop iterations may be used to access each of the objects Selector

3, extract information

  Selector call or SelectorList object method can extract the selected content

    extract

      The method will extract all the results collected SelectorList object to a list is returned to the user

    re

      Use regular expressions to extract the desired content

    extract_first

      Selector object returns the first result of calling the extract method. SelectorList object usually contains only a Selector object when this method is invoked

    re_first

 

Guess you like

Origin www.cnblogs.com/tulintao/p/11697940.html