先上HTML文檔
<html> <body> <a href="http://www.example.com">Example</a> <a href="http://www.stackoverflow.com">SO</a> </body> </html>
上次用了正常情況下的xpth獲取/html/body//a/@href就可以了
結果selenium報錯…經過一番了解之后才知道大坑啊。。。
a = /html/body//a # 這里獲取到a標簽就好了
a.get_attribute('href') # 這樣就可以獲取到href的鏈接了