我正在编辑一个旧的潦草的脚本。对于某些页面,“Bathrooms”字段不存在。如果它不存在,我想输入一个“0”
我可以用pandas进行后期处理,但现在我想在scrapy脚本中实现这一点
我试过了,但有个错误
城镇。py“,第88行 其他: ^ 语法错误:无效语法
bathrooms_txt = response.xpath(".//dt[contains(text(), 'Bathrooms')]/following-sibling::dd/text()").extract_first()
if bathrooms_txt == "":
bathrooms = "0"
else:
bathrooms = bathrooms_txt
except:
pass
编辑piplines.py
extract_first
方法的default
参数可用于以下情况:或:
看起来你可能把你的try语句搞砸了
你的意思是:
相关问题 更多 >
编程相关推荐