侧边栏壁纸
博主头像
落叶人生博主等级

走进秋风,寻找秋天的落叶

  • 累计撰写 130562 篇文章
  • 累计创建 28 个标签
  • 累计收到 9 条评论
标签搜索

目 录CONTENT

文章目录

xpath ,css

2023-01-21 星期六 / 0 评论 / 0 点赞 / 83 阅读 / 1339 字

https://docs.scrapy.org/en/latest/intro/tutorial.html xpath @选择属性 .当前目录下选择 //任意路径选择 /bookstore/book

... .

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.

. .. ...

广告 广告

评论区