scrapy shell use case

  1. Use scrapy shell http://bj.maitian.cn/esfall to visit Maitian Real Estate Beijing's second-hand house and get response: the first page of html
  2. Objective: To obtain the information of title, price, area and district
  3. Title: response.xpath ('// div [@ class = "list_title"] / h1 / a / text ()'). Extract_first ()
    extract_first (): extract only the first value
    // div: find all divs Tag
    [@ class = ""]: Find by tag attribute value
  4. 价格:response.xpath('//div[@class="list_title"]/div[@class="the_price"]/ol/strong/span/text()').extract()
  5. 面积:response.xpath('//div[@class="list_title"]/p/span/text()').extract_first()
  6. 区:response.xpath('//div[@class="list_title"]/p[@class="house_hot"]/span/text()').extract_first()

Guess you like

Origin www.cnblogs.com/wuweixiong/p/12751295.html