首页 > 解决方案 > How to get the path of tag if it has a space in its class or id

问题描述

I am trying to get the path of the tags with class name(using cheerio). I tried

let title =$('div.group-flag > div >a').text(); 

this works fine. I am trying to get text required.

I tried

let title=$('//span[starts-with(@class,"js-course-title")]') 

this gives an error.

$('span[class="js-course-title.d-none.d-sm-block"]') 

this returns no values (or length=0). Please let me know how can I get the text required?

标签: htmljquerycheerio

解决方案


任何一个

$('[class="c-ad-carousel__subtitle c-ad-carousel__subtitle--location c-ad-carousel__subtitle--small"]')

或者

$('.c-ad-carousel__subtitle.c-ad-carousel__subtitle--location.c-ad-carousel__subtitle--small')

推荐阅读