我有这个简单的 html 代码:
<html>
<head></head>
<body>
<p>
<span class="bold-title">This is</span>
" a test"
</p>
</body>
</html>
我想通过使用 webbot 的 xpath 进行“测试”
似乎“有效”的代码是:
from webbot import Browser
driver = Browser(showWindow=True)
driver.go_to('file:///C:/Users/myself/Desktop/test.html')
outp = driver.execute_script("return document.evaluate('/html/body/p/text()', document, null, XPathResult.FIRST_ORDERED_NODE_TYPE, null).singleNodeValue;")
print(outp)
xpath "/html/body/p/text()" 理论上应该返回 "a test",但是 webbot 决定打印 "[None, None, None, None, None, None, None]",什么是继续吗?