因此,我试图创建一个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语句的代码运行正常。
我想通了!抱歉。
test =(driver.execute_script(“ return document.body.innerText.includes('sold out')”))