简体   繁体   English

Cheerio如何获取一个元素的标签名称

[英]Cheerio how to get the tag name of one element

I am using Cheerio to scrape one web site, i need to know the tag name of the element, but according to Cheerio API there is not any property that retrieve that.我正在使用 Cheerio抓取一个 web 站点,我需要知道元素的标签名称,但根据 Cheerio API 没有任何属性可以检索它。 My snippet of code:我的代码片段:

const links = $("body").find("path...");
link.each((i,elem)=>{
   elem.name;
});

i am using typescript in NodeJs,Typescript throws an error saying that this property does not even exist.我在 NodeJs 中使用 typescript,Typescript 抛出一个错误,说这个属性甚至不存在。

Thanks in advance.提前致谢。 Best regards.此致。

I found the answer $(element).get(0).tagName我找到了答案 $(element).get(0).tagName

Thanks谢谢

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM