简体   繁体   中英

Strip html tags, css and js code from string

I am using document.documentElement.textContent.toLowerCase() to read a website text content, the problem is this website has so many css and js code before any real text that I don't even get the complete text, it gets trunked in some part of the css.

How can I remove all the css and js code to retrieve only the text content?

那这个呢?

var text = document.getElementsByTagName('body')[0].textContent.toLowerCase();

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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