python - Scraper - 如何保存和存储表情符号
问题描述
我目前在 python 3.x 和 ubuntu 环境下使用来自https://scrapy.org/的 Scraper ,不知何故我想在论坛中获得用户评论,其中包含文本和表情符号。
想知道我们如何将这些表情符号保存到一个数组中,以便我可以在 cvs 或 json 中看到它?
谢谢
解决方案
如果您至少可以提供页面的 HTML,那就太好了。
如果 emoji 和文本包含在父元素中,假设 div 带有如下注释类。
<div class="comment">
<div class="description">This is a comment.</div>
<span>:-)</span>
</div>
那么您可以使用以下 XPath 或 CSS 选择器。
response.css('.comment ::text').extract()
或者
response.xpath('.//div[@class="comment"]//text()').extract()
推荐阅读
- liquibase - 当没有任何更改时,Liquibase 会生成 dropdefault 更改集
- django - 即使在进行迁移之后,/admin/login/ 处的 OperationalError
- iframe - Blogger 模板无法全屏播放视频
- python - 执行 PEP-585 的 Linting
- typescript - 重构令牌刷新动作
- html - :read-only 伪元素所针对的非禁用复选框
- python - 用 python scrapy 和 BeautifulSoup 抓取网页?
- python - 如何在固定的背景图像下方滚动
- go - 部署在 GKE 上的 Go API 抛出 SSL Error: Unable to verify the first certificate 。我错过了什么吗?
- java - 虽然我写了 'enctype="multipart/form-data',但发生错误'当前请求不是多部分请求'