OR operator for JSOUP select() method

|▌冷眼眸甩不掉的悲伤 提交于 2019-12-31 04:19:08

问题


I am trying to find all <div class="name1"> or <div class="name2"> tags in one page/document.

How can I use OR operator in doc.select("div.name1 OR div.name2")?


回答1:


The select method of JSoup implements more or less the CSS selector syntax. So you can very simply use the CSS way of specifying alternatives, i.e. using ,. This should work:

doc.select("div.name1,div.name2");


来源:https://stackoverflow.com/questions/24485013/or-operator-for-jsoup-select-method

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!