我正在尝试在特定位置获取特定字符串。我拥有的字符串是html页面中的Json,我试图使用html标记定位它,但我无法The site I want to scarap
我想要得到的字符串是:"isOnlyFewLeft":false,"isOutOfStock":false,"isRopisEligibleSku":true,"isSephoraExclusive":false,"
我尝试了以下模式:'''"isOutOfStock": (.*?), "isRopisEligibleSku"'''
,但它不起作用。
我的代码:```
def Filter(self):
try:
print(self.sourcepage)
match = re.search('''"isOutOfStock": (.*?), "isRopisEligibleSku"''', self.sourcepage)
print(match)
if match:
print(match.group())
except BaseException as e:
print(e)```
尝试通过将
script
HTML元素解析为JSON来获取所需值:输出:
相关问题 更多 >
编程相关推荐