Xpath:如果包含特定单词,则获取 href

Xpath: obtain href if contains specific word

设置

我正在使用以下 xpath 从页面中提取 href,

'/html/body/div/div[2]/div[2]/div/div/p[1]/a/@href'

这给了我一个看起来像

的 href 列表
['#',
 'showv2.php?p=Glasgow City&t=Anderston',
 'showv2.php?p=Glasgow City&t=Anniesland',
 'showv2.php?p=Glasgow City&t=Ashfield',
 '#',
 'showv2.php?p=Glasgow City&t=Baillieston',
           ⋮
'showv2.php?p=Glasgow City&t=Yoker']


问题

我对 '#' href 不感兴趣。我感兴趣的所有 href 都包含 Glasgow。如何只 select 包含 Glasgow 的 href?

我已经看到关于 'id' 等正则表达式的答案,但没有看到 href。这些答案似乎不适用于 href。

我已经看到关于 href 开头或结尾的正则表达式的答案,但我希望能够对 'containing' 单词进行正则表达式。

a 个元素上使用 contains(@href, 'Glasgow') "restriction":

'/html/body/div/div[2]/div[2]/div/div/p[1]/a[contains(@href, "Glasgow")]/@href'

然后,它将只查找指定路径下的那些 href 属性值中包含 Glasgow<a>