小编ric*_*row的帖子

每次我在 VSCode 中打开终端时都会出现“setup.py install is deprecated”警告

每次在 VSCode 上启动终端时,都会收到以下提示。Terminal.app 上不会发生这种情况。

    /usr/local/lib/python3.9/site-packages/setuptools/command/install.py:34:
SetuptoolsDeprecationWarning: setup.py install is deprecated. Use build and pip
and other standards-based tools.
Run Code Online (Sandbox Code Playgroud)

我该如何解决这个问题?

python visual-studio-code

32
推荐指数
4
解决办法
10万
查看次数

不是“\u”:如何在 JSON 中取消转义 Unicode?

我正在尝试使用 Scrapy 从非英语网站上抓取。JSON 格式的抓取结果如下所示:

{"price": "13,000", "name": "\u58c1\u6bb4\u308a\u4ee3\u884c\u69d8\u5c02\u7528\u2605 \u30c6\u30ec\u30d3\u672c\u4f53 20v\u578b \u767d \u9001\u6599\u8fbc"},
Run Code Online (Sandbox Code Playgroud)

这是我正在使用的代码:

def parse(self, response):
    for sel in response.xpath('//section[@class="items-box"]'):
      item = ShopItem()
      item['name'] = sel.xpath('a/div/h3/text()').extract()
      item['price'] = sel.xpath('a/div/div/div[1]/text()').extract().replace("$", "")
      yield item
Run Code Online (Sandbox Code Playgroud)

我如何将未转义的 Unicode 字符输出到 JSON 上?

python unicode encoding json scrapy

4
推荐指数
2
解决办法
3005
查看次数

替换Scrapy项目中的字符

我正试图从使用Scrapy的商业网站上刮掉.对于价格标签,我想删除"$",但我当前的代码不起作用.

  def parse(self, response):
    for sel in response.xpath('//section[@class="items-box"]'):
      item = ShopItem()
      item['name'] = sel.xpath('a/div/h3/text()').extract()
      item['price'] = sel.xpath('a/div/div/div[1]/text()').extract().replace("$", "")
      yield item

AttributeError: 'list' object has no attribute 'replace'
Run Code Online (Sandbox Code Playgroud)

使用Scrapy时删除字符的适当方法是什么?

python scrapy web-scraping

3
推荐指数
1
解决办法
2069
查看次数