每次在 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)
我该如何解决这个问题?
我正在尝试使用 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 上?
我正试图从使用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时删除字符的适当方法是什么?