扫码关注官方订阅号
小伙看你根骨奇佳,潜力无限,来学PHP伐。
用strip()去掉首尾空格
from scrapy.selector import Selector content = "<p>数量:100-200个 </p>" strings = Selector(text=content).xpath('//p/text()').re_first(u'数量:(.+)\s$').strip() print(strings) print(len(strings)) """ 100-200个 8 """
'数量:(\S+)'
微信扫码关注PHP中文网服务号
QQ扫码加入技术交流群
Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号
PHP学习
技术支持
返回顶部
用strip()去掉首尾空格
'数量:(\S+)'