- 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
- Objective: To obtain the information of title, price, area and district
- 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 - 价格:response.xpath('//div[@class="list_title"]/div[@class="the_price"]/ol/strong/span/text()').extract()
- 面积:response.xpath('//div[@class="list_title"]/p/span/text()').extract_first()
- 区:response.xpath('//div[@class="list_title"]/p[@class="house_hot"]/span/text()').extract_first()
scrapy shell use case
Guess you like
Origin www.cnblogs.com/wuweixiong/p/12751295.html
Recommended
Ranking