Python将javascript传递给true / false

问题描述 投票:0回答:1

因此,我试图创建一个python程序来检查某件商品是否有库存或无货。为此,我使用了硒铬Web驱动程序。为了检查物品是否有库存,我使用此代码:

print(driver.execute_script("return document.body.innerText.includes('sold out')"))

我希望在if语句中使用它,这样如果它返回true / false,我可以使其运行Discord webhook。

if(driver.execute_script("return document.body.innerText.includes('sold out')" == 'False')):

没有if语句的代码运行正常。

python selenium web driver
1个回答
0
投票

我想通了!抱歉。

test =(driver.execute_script(“ return document.body.innerText.includes('sold out')”))

© www.soinside.com 2019 - 2024. All rights reserved.