• 博客园logo
  • 会员
  • 周边
  • 众包
  • 新闻
  • 博问
  • 闪存
  • 赞助商
  • Chat2DB
    • 搜索
      所有博客
    • 搜索
      当前博客
  • 写随笔 我的博客 短消息 简洁模式
    用户头像
    我的博客 我的园子 账号设置 会员中心 简洁模式 ... 退出登录
    注册 登录
oooooolr
You can do anything but not everything. ——David Allen
博客园    首页    新随笔    联系   管理    订阅  订阅

xpath ,css

https://docs.scrapy.org/en/latest/intro/tutorial.html

xpath @选择属性  .当前目录下选择 //任意路径选择

/bookstore/book[position()<3],选取最前面的两个属于 bookstore 元素的子元素的 book 元素

 css span.text::text

 response.css("span.text").text().get() ///  AttributeError: 'SelectorList' object has no attribute 'text'

 

quote.css("span.text::text").get() 选择span下面text的text()标签内容

 

scrapy crawl quotes -o quotes.json

 

That will generate an quotes.json file containing all scraped items, serialized in JSON.

 

For historic reasons, Scrapy appends to a given file instead of overwriting its contents. If you run this command twice without removing the file before the second time, you’ll end up with a broken JSON file.

 

-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- focus on what you want to be
posted @ 2019-02-13 20:32  oooooolr  阅读(113)  评论(0)    收藏  举报
刷新页面返回顶部
博客园  ©  2004-2025
浙公网安备 33010602011771号 浙ICP备2021040463号-3