python - 如何在使用response.css提取时删除/n和逗号

标签 python css web-scraping

我正在尝试抓取亚马逊以获取产品名称、价格和[节省信息]。我正在使用response.css来提取[保存信息],如下

提取[储蓄信息]的python代码:

savingsinfo = amzscrape.css(".a-color-secondary .a-row , .a-row.a-size-small.a-color-secondary span").css('::text').extract()

使用上面的代码返回下面的输出

'savingsinfo_item': ['Save ',                                                   
                     '$20.00',
                     ' when you buy ',
                     '$100.00',
                     ' of select items']

预期输出:

Save $20.00 when you buy $100 of select items

最佳答案

output = ''.join(savingsinfo['savingsinfo_item'])

关于python - 如何在使用response.css提取时删除/n和逗号,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58619136/

相关文章:

python - 如何对不同长度的 "identical"字符串进行 GROUP BY?

python - 基本的字符串和变量python

html - 填充窗口的剩余高度

r - R 中的网页抓取

html - 使用 nokogiri 抓取后字符串的正则表达式是什么

python - 如何传递传递参数以从 xml request.get python 中获取值

python - 插入多个参数的优雅方式

python - PyInstaller 无法通过 pip 安装

css - 显示细节和摘要的问题以及重新对齐的 webkit 标记(包括 jsfiddle)、CSS3 和 HTML5

html - 从 Bootstrap Accordion 控件中删除边框