项目名py文件下

class DsSpider(CrawlSpider):
name = 'ds'
allowed_domains = ['dushu.com']
start_urls = ['https://www.dushu.com/book/1163_1.html'] rules = (
Rule(LinkExtractor(restrict_xpaths='//div[@class="pages"]'), callback='parse_item', follow=True),
) def parse_item(self, response):
item = {}
# print(response.url)
lis = response.xpath('//div[@class="bookslist"]/ul/li')
for li in lis:
item['name'] = li.xpath('.//h3/a/text()').extract_first()
item['link'] = li.xpath('.//h3/a/@href').extract_first()
item['author'] = li.xpath('.//p[1]/a/text()').extract_first()
#item['domain_id'] = response.xpath('//input[@id="sid"]/@value').get()
#item['name'] = response.xpath('//div[@id="name"]').get()
#item['description'] = response.xpath('//div[@id="description"]').get()
yield item

最新文章

  1. 关于django xadmin的学习改造(菜单名称,更改默认前缀数据库)
  2. perl文件句柄的传递
  3. 华清远见金牌讲师名家大讲堂Android开发篇成功举办
  4. XAMPP(Linux版-x86兼容)官网下载
  5. 关于javascript tween的学后小感想
  6. [C#基础]Func和Action学习
  7. iOS block 声明时和定义时的不同格式
  8. php安装libevent
  9. yarn安装部署
  10. Android 属性动画(Property Animation) 全然解析 (下)
  11. Z-Stack协议中几个重要概念的理解
  12. mysql 数据库优化要点
  13. mysql常用基础操作语法(十)~~子查询【命令行模式】
  14. POJ1743 Musical Theme(二分+后缀数组)
  15. 如何清除保存在IE浏览器上的账号密码
  16. Tomcat如何发布web项目
  17. Vue(六)过滤器
  18. java微信小程序调用支付接口(转)
  19. Rspec: everyday-rspec实操。5:controller test(了解基础)
  20. Java数组初始

热门文章

  1. ng 循环数据
  2. Thinkphp5.0第二篇
  3. (转) websocket 和 socket 剖析
  4. Linux内核版本介绍与查询
  5. 6个Linux运维典型问题,看大牛的分析解决思路
  6. Jenkins介绍
  7. Springboot 系列(十四)迅速启用 HTTPS 加密你的网站
  8. PHP get_object_vars 和 get_class_vars
  9. 一个关于内联优化和调用约定的Bug
  10. HDU 6112 今夕何夕 (预处理 枚举)