我需要在 Bash 脚本中获取一些超引用。
以下命令使用curl
andxmllint
读取href
HTML 页面的所有属性:
curl --silent -L google.com | xmllint --html --xpath '//a/@href' -
但我只需要属性的值。可以使用string()
函数选择属性的值。但是如果我使用它,我只会得到属性列表的第一个元素:
curl --silent -L google.com | xmllint --html --xpath 'string(//a/@href)' -
如何将string()
函数应用于每个属性?