??????.py 文件源码

python
阅读 23 收藏 0 点赞 0 评论 0

项目:User-Python-Write-a-web-crawler 作者: xiexiaoshinick 项目源码 文件源码
def parse(self, response):
        item=AutopjtItem()
#?Xpath????????
        item["name"]=response.xpath("//a[@class='pic']/@title").extract()
        item["price"]=response.xpath("//span[@class='price_n']/text()").extract()
        item["link"]=response.xpath("//a[@class='pic']/@href").extract()
        item["comnum"]=response.xpath("//a[@name='P_pl']/text()").extract()
#???item
        yield item
#??????75?
        for i in range(1,76):
#???????
            url="http://category.dangdang.com/pg"+str(i)+"-cid4002203.html"
#?yieldRequest??????
#???
            yield Request(url, callback=self.parse)

#15.5 
#1
# Obey robots.txt rules
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号