前端爬虫工具 web-crawl-util
在我们的端对端测试方案中,很重要的一个步骤就是将页面快照转换为数据快照,其中一块就是需要从 dom 结构中获得需要的数据。为了简化操作,我们提供了 web-crawl-util 这个工具库。
如何使用
安装:
npm install web-crawl-util使用:
const { useJquery } = require('web-crawl-util');
console.log(useJquery.getText('#id .css'));API
工具提供了一个 useJquery 对象,其包含了如下几个方法,更详细文档请参考 web-crawl-util 。
getText(jqCur, jqContainer),获得文字信息getAttr(name, jqCur, jqContainer),获得属性值getTotal(jqCur, jqContainer),获得符合条件的DOM数量isExist(jqCur, jqContainer),是否存在getImageDomUrl(jqCur, jqContainer),获得 img 标签中图片的地址getStyle(jqCur, jqContainer),获得 dom 元素中的部分计算属性值getBackgroundImageUrl(jqCur, jqContainer),获得background-image属性中图片的链接
Last updated
Was this helpful?