如何具有多个上下文选择器?

问题描述 投票:0回答:1

我目前正在研究围巾

我当前代码的全部看起来像这样

contextSelector = 'a[href^="/clubs-and-societies/academic/'; 

(此方法有效)

但是有多个页面可供选择,但是没有多个ContextSelector不能工作

contextSelector = 'a[href^="/clubs-and-societies/academic/'; 
    contextSelector = 'a[href^="/clubs-and-societies/culture/';
    contextSelector = 'a[href^="/clubs-and-societies/dance/';  

(不起作用)

解决方案是什么?

web-scraping css-selectors
1个回答
0
投票
两点:

1)您的语法格式不正确。应该是:

contextSelector = 'a[href^="/clubs-and-societies/academic/"]';

((请注意,双引号"和右方括号]。]

2)CSS中的逻辑OR是逗号,

contextSelector = 'a[href^="/clubs-and-societies/academic/"], a[href^="/clubs-and-societies/culture/"], a[href^="/clubs-and-societies/dance/"]';

© www.soinside.com 2019 - 2024. All rights reserved.