How to get html elements with multiple css classes

前端 未结 4 1450
渐次进展
渐次进展 2020-11-28 06:57

I know how to get a list of DIVs of the same css class e.g

1
2
4条回答
  •  悲&欢浪女
    2020-11-28 07:44

    There's a useful python package called cssselect.

    from cssselect import CSSSelector CSSSelector('div.gallery').path

    Generates a usable XPath:

    descendant-or-self::div[@class and contains(concat(' ', normalize-space(@class), ' '), ' gallery ')]
    

    It's very similar to Flynn1179's answer.

提交回复
热议问题