
17

如何实现在网页中,移动鼠标点击元素就能获取到相应的代码或元素选择器?
source link: https://www.zhihu.com/question/521224922/answer/2387023817
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.

如何实现在网页中,移动鼠标点击元素就能获取到相应的代码或元素选择器?
如在浏览器中检查相应元素代码的效果,在网页中获取元素的对应标签,像八爪鱼采集器在网页中选取元素的效果 [视频]
4
252
登录后你可以
不限量看优质回答私信答主深度交流精彩内容一键收藏
对于获取相应的元素选择器,我曾经有过这个需求
一开始是自己写了一套根据元素以及其全部父元素的 id class 标签名 生成对应 css选择器的
后面发现浏览器f12 中提供的比我写的要好得多
于是就抄了
代码在这,你如果不熟悉ts的话
简单的利用一下
转换为 js 使用
使用方式很简单 ,调用 cssPath 函数即可

结合
的回答简单改造下即可Recommend
About Joyk
Aggregate valuable and interesting links.
Joyk means Joy of geeK