MongoDB - 聚合阶段 $match、$sort、$limit
文章目录
- 1. $match 聚合阶段
- 1. 构造测试数据
- 2. $match 示例
- 3. $match 示例
- 2. $sort 聚合阶段
- 1. 排序一致性问题
- 2. $sort 示例
- 3. $limit 聚合阶段
1. $match 聚合阶段
$match
接受一个指定查询条件的文档。
$match
阶段语法:
{ $match: { <query> } }
$match
查询语法与读取操作查询语法相同,即 $match
不接受原始聚合表达式。要在 $match
中包含聚合表达式,请使用 $expr
查询表达式:
{ $match: { $expr: { <aggregation expression> } } }
尽可能早地将 $match
放在聚合管道中,由于 $match
限制了聚合管道中的文档总数,因此早期的 $match
操作会最大限度地减少管道中的处理量。
1. 构造测试数据
db.articles.drop()db.articles.insertMany([{"_id": ObjectId("512bc95fe835e68f199c8686"),"author": "dave","score": 80,"views": 100},{"_id": ObjectId("512bc962e835e68f199c8687"),"author": "dave","score": 85,"views": 521},{"_id": ObjectId("55f5a192d4bede9ac365b257"),"author": "ahn","score": 60,"views": 1000},{"_id": ObjectId("55f5a192d4bede9ac365b258"),"author": "li","score": 55,"views": 5000},{"_id": ObjectId("55f5a1d3d4bede9ac365b259"),"author": "annT","score": 60,"views": 50},{"_id": ObjectId("55f5a1d3d4bede9ac365b25a"),"author": "li","score": 94,"views": 999},{"_id": ObjectId("55f5a1d3d4bede9ac365b25b"),"author": "ty","score": 95,"views": 1000}
])
2. $match 示例
使用 $match
来执行简易等值匹配,$match
会选择 author
字段等于 dave
的文档,而聚合返回以下内容:
db.articles.aggregate([ { $match : { author : "dave" } } ]
);
// 1
{"_id": ObjectId("512bc95fe835e68f199c8686"),"author": "dave","score": 80,"views": 100
}// 2
{"_id": ObjectId("512bc962e835e68f199c8687"),"author": "dave","score": 85,"views": 521
}
SpringBoot 整合 MongoDB 实现:
@SpringBootTest
@RunWith(SpringRunner.class)
public class BeanLoadServiceTest {@Autowiredprivate MongoTemplate mongoTemplate;@Testpublic void aggregateTest() {// $match阶段Criteria criteria = Criteria.where("author").is("dave");MatchOperation match = Aggregation.match(criteria);Aggregation aggregation = Aggregation.newAggregation(match);// 执行聚合管道操作AggregationResults<Article> results= mongoTemplate.aggregate(aggregation, Article.class, Article.class);List<Article> mappedResults = results.getMappedResults();// 打印结果mappedResults.forEach(System.out::println);//Article(id=512bc95fe835e68f199c8686, author=dave, score=80, views=100)//Article(id=512bc962e835e68f199c8687, author=dave, score=85, views=521)}
}
这里输出文档直接使用了Article.class,可以重新定义实体类接收输出文档的字段:
@Data
public class AggregationResult {@Idprivate String id;private String author;private int score;private int views;
}
@SpringBootTest
@RunWith(SpringRunner.class)
public class BeanLoadServiceTest {@Autowiredprivate MongoTemplate mongoTemplate;@Testpublic void aggregateTest() {// $match阶段Criteria criteria = Criteria.where("author").is("dave");MatchOperation match = Aggregation.match(criteria);Aggregation aggregation = Aggregation.newAggregation(match);// 执行聚合管道操作AggregationResults<AggregationResult> results= mongoTemplate.aggregate(aggregation, Article.class, AggregationResult.class);List<AggregationResult> mappedResults = results.getMappedResults();// 打印结果mappedResults.forEach(System.out::println);//AggregationResult(id=512bc95fe835e68f199c8686, author=dave, score=80, views=100)//AggregationResult(id=512bc962e835e68f199c8687, author=dave, score=85, views=521)}
}
3. $match 示例
使用 $match
管道操作符选择要处理的文档,然后将结果导入到 $group
管道操作符,以计算文档的数量:
db.articles.aggregate( [// 第一阶段{ $match: { $or: [ { score: { $gt: 70, $lt: 90 } }, { views: { $gte: 1000 } } ] } },// 第二阶段{ $group: { _id: null, count: { $sum: 1 } } }
] );
第一阶段:
$match 阶段选择 score
大于 70
但小于 90
或 views
大于或等于 1000
的文档。
第二阶段:
将 m a t c h 阶段筛选的文档通过管道传送到 ‘ match 阶段筛选的文档通过管道传送到 ` match阶段筛选的文档通过管道传送到‘group` 阶段进行计数。
// 1
{"_id": null,"count": 5
}
SpringBoot 整合 MongoDB 实现:
@Data
@Document(collection = "articles")
public class Article {@Idprivate String id;private String author;private int score;private int views;
}
@Data
public class AggregationResult {private String id;private Integer count;
}
@SpringBootTest
@RunWith(SpringRunner.class)
public class BeanLoadServiceTest {@Autowiredprivate MongoTemplate mongoTemplate;@Testpublic void aggregateTest() {// 第一阶段Criteria criteria = new Criteria();criteria.orOperator(Criteria.where("score").gt(70).lt(90), Criteria.where("views").gte(1000));MatchOperation match = Aggregation.match(criteria);// 第二阶段GroupOperation group = Aggregation.group().count().as("count");// 组合上面的2个阶段Aggregation aggregation = Aggregation.newAggregation(match,group);// 执行聚合管道操作AggregationResults<AggregationResult> results= mongoTemplate.aggregate(aggregation, Article.class, AggregationResult.class);List<AggregationResult> mappedResults = results.getMappedResults();// 打印结果mappedResults.forEach(System.out::println);// AggregationResult(id=null, count=5)}
}
2. $sort 聚合阶段
$sort 将所有输入文档进行排序,然后按照排序将其返回至管道。
{ $sort: { <field1>: <sort order>, <field2>: <sort order> ... } }
$sort
接受排序依据的字段及相应排序顺序的文档。当 sort order=1时升序排序,sort order=-1 降序排序。
如果对多个字段进行排序,则按从左到右的顺序进行排序。例如,在上面的表单中,文档首先按 field1 排序。然后,具有相同 field1 值的文档将按 field2 进一步排序。
1. 排序一致性问题
MongoDB 不按特定顺序将文档存储在集合中。对包含重复值的字段进行排序时,可能会以任何顺序返回包含这些值的文档。如果需要一致的排序顺序,请在排序中至少纳入一个包含唯一值的字段。
db.restaurants.drop()db.restaurants.insertMany( [{ "_id" : 1, "name" : "Central Park Cafe", "borough" : "Manhattan"},{ "_id" : 2, "name" : "Rock A Feller Bar and Grill", "borough" : "Queens"},{ "_id" : 3, "name" : "Empire State Pub", "borough" : "Brooklyn"},{ "_id" : 4, "name" : "Stan's Pizzaria", "borough" : "Manhattan"},{ "_id" : 5, "name" : "Jane's Deli", "borough" : "Brooklyn"},
] )
以下命令使用 $sort
阶段对 borough
字段进行排序:
db.restaurants.aggregate([{ $sort : { borough : 1 } }]
)
在此示例中,排序顺序可能不一致,因为 borough
字段包含 Manhattan
和 Brooklyn
的重复值。文档按 borough
的字母顺序返回,但具有 borough
重复值的文档的顺序在多次执行同一排序中可能不相同。
要实现一致的排序,可以在排序中添加一个仅包含唯一值的字段。以下命令使用 $sort
阶段对 borough
字段和 _id
字段进行排序:
db.restaurants.aggregate([{ $sort : { borough : 1, _id: 1 } }]
)
由于 _id
字段始终保证包含唯一值,因此在同一排序的多次执行中返回的排序顺序将始终相同。
2. $sort 示例
db.articles.drop()db.articles.insertMany([{"_id": ObjectId("512bc95fe835e68f199c8686"),"author": "dave","score": 80,"views": 100},{"_id": ObjectId("512bc962e835e68f199c8687"),"author": "dave","score": 85,"views": 521},{"_id": ObjectId("55f5a192d4bede9ac365b257"),"author": "ahn","score": 60,"views": 1000},{"_id": ObjectId("55f5a192d4bede9ac365b258"),"author": "li","score": 55,"views": 5000},{"_id": ObjectId("55f5a1d3d4bede9ac365b259"),"author": "annT","score": 55,"views": 50},{"_id": ObjectId("55f5a1d3d4bede9ac365b25a"),"author": "li","score": 94,"views": 999},{"_id": ObjectId("55f5a1d3d4bede9ac365b25b"),"author": "ty","score": 95,"views": 1000}
])
对于要作为排序依据的一个或多个字段,可以将排序顺序设置为 1
或 -1
以分别指定升序或降序。
db.articles.aggregate([{ $sort : { score : -1, views: 1 } }]
)
// 1
{"_id": ObjectId("55f5a1d3d4bede9ac365b25b"),"author": "ty","score": 95,"views": 1000
}// 2
{"_id": ObjectId("55f5a1d3d4bede9ac365b25a"),"author": "li","score": 94,"views": 999
}// 3
{"_id": ObjectId("512bc962e835e68f199c8687"),"author": "dave","score": 85,"views": 521
}// 4
{"_id": ObjectId("512bc95fe835e68f199c8686"),"author": "dave","score": 80,"views": 100
}// 5
{"_id": ObjectId("55f5a192d4bede9ac365b257"),"author": "ahn","score": 60,"views": 1000
}// 6
{"_id": ObjectId("55f5a1d3d4bede9ac365b259"),"author": "annT","score": 55,"views": 50
}// 7
{"_id": ObjectId("55f5a192d4bede9ac365b258"),"author": "li","score": 55,"views": 5000
}
SpringBoot 整合 MongoDB:
@Data
@Document(collection = "articles")
public class Article {@Idprivate String id;private String author;private int score;private int views;
}@Data
public class AggregationResult {@Idprivate String id;private String author;private int score;private int views;
}
@SpringBootTest
@RunWith(SpringRunner.class)
public class BeanLoadServiceTest {@Autowiredprivate MongoTemplate mongoTemplate;@Testpublic void aggregateTest() {// $sort阶段SortOperation sortOperation = Aggregation.sort(Sort.by(Sort.Direction.DESC, "score")).and(Sort.by(Sort.Direction.ASC, "views"));Aggregation aggregation = Aggregation.newAggregation(sortOperation);// 执行聚合查询AggregationResults<AggregationResult> results= mongoTemplate.aggregate(aggregation, Article.class, AggregationResult.class);List<AggregationResult> mappedResults = results.getMappedResults();// 打印结果mappedResults.forEach(System.out::println);//AggregationResult(id=55f5a1d3d4bede9ac365b25b, author=ty, score=95, views=1000)//AggregationResult(id=55f5a1d3d4bede9ac365b25a, author=li, score=94, views=999)//AggregationResult(id=512bc962e835e68f199c8687, author=dave, score=85, views=521)//AggregationResult(id=512bc95fe835e68f199c8686, author=dave, score=80, views=100)//AggregationResult(id=55f5a192d4bede9ac365b257, author=ahn, score=60, views=1000)//AggregationResult(id=55f5a1d3d4bede9ac365b259, author=annT, score=55, views=50)//AggregationResult(id=55f5a192d4bede9ac365b258, author=li, score=55, views=5000)}
}
3. $limit 聚合阶段
$limit
聚合阶段限制传递至管道。$limit
取一个正整数,用于指定传递的最大文档数量:
{ $limit: <positive 64-bit integer> }
如果将 $limit
阶段与以下任何一项一起使用:
$sort
聚合阶段sort()
方法sort
命令
在将结果传递到$limit
阶段之前,请务必在排序中至少包含一个包含唯一值的字段。
db.articles.drop()db.articles.insertMany([{"_id": ObjectId("512bc95fe835e68f199c8686"),"author": "dave","score": 80,"views": 100},{"_id": ObjectId("512bc962e835e68f199c8687"),"author": "dave","score": 85,"views": 521},{"_id": ObjectId("55f5a192d4bede9ac365b257"),"author": "ahn","score": 60,"views": 1000},{"_id": ObjectId("55f5a192d4bede9ac365b258"),"author": "li","score": 55,"views": 5000},{"_id": ObjectId("55f5a1d3d4bede9ac365b259"),"author": "annT","score": 60,"views": 50},{"_id": ObjectId("55f5a1d3d4bede9ac365b25a"),"author": "li","score": 94,"views": 999},{"_id": ObjectId("55f5a1d3d4bede9ac365b25b"),"author": "ty","score": 95,"views": 1000}
])
db.articles.aggregate([{ $limit : 5 }
]);
// 1
{"_id": ObjectId("512bc95fe835e68f199c8686"),"author": "dave","score": 80,"views": 100
}// 2
{"_id": ObjectId("512bc962e835e68f199c8687"),"author": "dave","score": 85,"views": 521
}// 3
{"_id": ObjectId("55f5a192d4bede9ac365b257"),"author": "ahn","score": 60,"views": 1000
}// 4
{"_id": ObjectId("55f5a192d4bede9ac365b258"),"author": "li","score": 55,"views": 5000
}// 5
{"_id": ObjectId("55f5a1d3d4bede9ac365b259"),"author": "annT","score": 55,"views": 50
}
SpringBoot 整合 MongoDB:
@Data
@Document(collection = "articles")
public class Article {@Idprivate String id;private String author;private int score;private int views;
}@Data
public class AggregationResult {@Idprivate String id;private String author;private int score;private int views;
}
@SpringBootTest
@RunWith(SpringRunner.class)
public class BeanLoadServiceTest {@Autowiredprivate MongoTemplate mongoTemplate;@Testpublic void aggregateTest() {// $sort阶段LimitOperation limitOperation = Aggregation.limit(5);Aggregation aggregation = Aggregation.newAggregation(limitOperation);// 执行聚合查询AggregationResults<AggregationResult> results= mongoTemplate.aggregate(aggregation, Article.class, AggregationResult.class);List<AggregationResult> mappedResults = results.getMappedResults();// 打印结果mappedResults.forEach(System.out::println);//AggregationResult(id=512bc95fe835e68f199c8686, author=dave, score=80, views=100)//AggregationResult(id=512bc962e835e68f199c8687, author=dave, score=85, views=521)//AggregationResult(id=55f5a192d4bede9ac365b257, author=ahn, score=60, views=1000)//AggregationResult(id=55f5a192d4bede9ac365b258, author=li, score=55, views=5000)//AggregationResult(id=55f5a1d3d4bede9ac365b259, author=annT, score=55, views=50)}
}
相关文章:

MongoDB - 聚合阶段 $match、$sort、$limit
文章目录 1. $match 聚合阶段1. 构造测试数据2. $match 示例3. $match 示例 2. $sort 聚合阶段1. 排序一致性问题2. $sort 示例 3. $limit 聚合阶段 1. $match 聚合阶段 $match 接受一个指定查询条件的文档。 $match 阶段语法: { $match: { <query> } }$ma…...

ModuleNotFoundError: No module named ‘scrapy.utils.reqser‘
在scrapy中使用scrapy-rabbitmq-scheduler会出现报错 ModuleNotFoundError: No module named scrapy.utils.reqser原因是新的版本的scrapy已经摒弃了该方法,但是scrapy-rabbitmq-scheduler 没有及时的更新,所以此时有两种解决方法 方法一.将scrapy回退至旧版本,找到对应的旧版…...

vue3+ts+vite+electron+electron-packager打包成exe文件
目录 1、创建vite项目 2、添加需求文件 3、根据package.json文件安装依赖 4、打包 5、electron命令运行 6、electron-packager打包成exe文件 Build cross-platform desktop apps with JavaScript, HTML, and CSS | Electron 1、创建vite项目 npm create vitelatest 2、添…...

使用脚本搭建MySQL数据库基础环境
数据库的基本概念 数据(Data) 描述事物的符号记录 包括数字,文字,图形。图像,声音,档案记录等。 以记录形式按统一格式进行存储 表 将不同的记录组织在一起 用来储存具体数据 数据库 表的集合,是…...

Parameter index out of range (2 > number of parameters, which is 1【已解决】
文章目录 1、SysLogMapper.xml添加注释导致的2、解决方法3、总结 1、SysLogMapper.xml添加注释导致的 <!--定义一个查询方法,用于获取日志列表--><!--方法ID为getLogList,返回类型com.main.server.api.model.SysLogModel,参数类型为com.main.se…...

rk3588s 定制版 USB adb , USB2.0与USB3.0 区别,adb 由typeC 转换到USB3.0(第二部分)
硬件资源: rk3588s 核心板定制的地板 软件资源: 网盘上的 android12 源码 1 硬件上 客户只想使用 type c 接口中的 usb2.0 OTG 。在硬件上,甚至连 CC芯片都没有连接。 关于一些前置的知识。 1 USB2.0 与 USB3.0 的区别。 usb3.0 兼容2.0 …...

Cookie与Session 实现登录操作
Cookie Cookie 是网络编程中使用最广泛的一项技术,主要用于辨识用户身份。 客户端(浏览器)与网站服务端通讯的过程如下图所示: 从图中看,服务端既要返回 Cookie 给客户端,也要读取客户端提交的 Cookie。所…...

通过IEC104转MQTT网关轻松接入阿里云平台
随着智能电网和物联网技术的飞速发展,电力系统中的传统IEC 104协议设备正面临向现代化、智能化转型的迫切需求。阿里云作为全球领先的云计算服务提供商,其强大的物联网平台为IEC 104设备的接入与数据处理提供了强大的支持。本文将深入探讨钡铼网关在MQTT…...
lua 游戏架构 之 游戏 AI (五)ai_autofight_find_way
这段Lua脚本定义了一个名为 ai_autofight_find_way 的类,继承自 ai_base 类。 lua 游戏架构 之 游戏 AI (一)ai_base-CSDN博客文章浏览阅读238次。定义了一套接口和属性,可以基于这个基础类派生出具有特定行为的AI组件。例如&…...

vue3+openLayers点击标记事件
<template><!--地图--><div class"distributeMap" id"distributeMap"></div> </template> <script lang"ts" setup> import { onMounted, reactive } from "vue"; import { Feature, Map, View }…...

深入分析 Android ContentProvider (三)
文章目录 深入分析 Android ContentProvider (三)ContentProvider 的高级使用和性能优化1. 高级使用场景1.1. 数据分页加载示例:分页加载 1.2. 使用 Loader 实现异步加载示例:使用 CursorLoader 加载数据 1.3. ContentProvider 与权限管理示例࿱…...

养宠浮毛异味双困扰?性价比高的宠物空气净化器推荐
家里养了两只银渐层,谁懂啊!一下班打开家门就看到家里飘满了猫浮毛雪,空气中还传来隐隐约约的异味。每天不是在吸毛的路上,就是在洗猫砂盆的路上,而且空气中的浮毛还很难清理干净,这是最让人头疼的问题。 …...

maven项目容器化运行之3-优雅的利用Jenkins和maven使用docker插件调用远程docker构建服务并在1Panel中运行
一.背景 在《maven项目容器化运行之1》中,我们开启了1Panel环境中docker构建服务给到了局域网。在《maven项目容器化运行之2》中,我们基本实现了maven工程创建、远程调用docker构建镜像、在1Panel选择镜像运行容器三大步骤。 但是,存在一个问…...

docker 打包orbbec
docker pull humble容器 sudo docker run -it osrf/ros:humble-desktop docker 启动容器 sudo docker run -u root --device/dev/bus/usb:/dev/bus/usb -it -v /home/wl:/share --name wl4 osrf/ros:humble-desktop /bin/bash新开一个终端 查看本地存在的容器:…...

无涯·问知财报解读,辅助更加明智的决策
财报解读就像是给公司做一次全面的体检,是理解公司内部运作机制和市场表现的一把钥匙,能够有效帮助投资者、分析师、管理层以及所有市场参与者判断一家公司的健康程度和发展潜力。 星环科技无涯问知的财经库内置了企业年报及财经类信息,并对…...

【Apache Doris】数据副本问题排查指南
【Apache Doris】数据副本问题排查指南 一、问题现象二、问题定位三、问题处理 本文主要分享Doris中数据副本异常的问题现象、问题定位以及如何处理此类问题。 一、问题现象 问题日志 查询报错 Failed to initialize storage reader, tablet{tablet_id}.xxx.xxx问题说明 查…...

【HarmonyOS】关于鸿蒙消息推送的心得体会(二)
【HarmonyOS】关于鸿蒙消息推送的心得体会(二) 前言 推送功能的开发与传统功能开发还是有很大区别。首先最大的区别点就在于需要多部门之间的协同,作为鸿蒙客户端开发,你需要和产品,运营,以及后台开发一起…...

零基础入门:创建一个简单的Python爬虫管理系统
摘要: 本文将手把手教你,从零开始构建一个简易的Python爬虫管理系统,无需编程基础,轻松掌握数据抓取技巧。通过实战演练,你将学会设置项目、编写基本爬虫代码、管理爬取任务与数据,为个人研究或企业需求奠…...

【Node.js基础04】node.js模块化
一:什么是模块化 在Node.js中,每个文件都可视为一个独立的模块。模块化提高了代码的复用性,按需加载,具有独立的作用域 二:如何实现多个文件间导入和导出 1 CommonJS标准(默认)-导入和导出 …...

数据库——单表查询
一、建立数据库mydb8_worker mysql> use mydb8_worker; 二、建立表 1.创建表 mysql> create table t_worker(department_id int(11) not null comment 部门号,-> worder_id int(11) primary key not null comment 职工号,-> worker_date date not null comment…...
dsa加训
refs: OI Wiki - OI Wiki (oi-wiki.org) 1. 枚举 POJ 2811 熄灯问题 refs : OpenJudge - 2811:熄灯问题 如果要枚举每个灯开或者不开的情况,总计2^30种情况,显然T。 不过我们可以发现:若第i行的某个灯亮了,那么有且仅有第i行和第…...

SpringBoot源码(1)ApplicationContext和BeanFactory
1、调用getBean方法 SpringBootApplication public class SpringBootDemoApplication {public static void main(String[] args) {ConfigurableApplicationContext applicationContext SpringApplication.run(SpringBootDemoApplication.class, args);applicationContext.get…...

CANoe编程实例--TCP/IP通信
1、简介 本实例将使用目前常用的开发工具C#来开发服务器端,以CANoe端作为客户端。服务器端和客户端,通过TCP/IP连接,实现数据交换。 首先在服务器端建立一个监听Socket,自动创建一个监听线程,随时监听是否有客户端的连…...

Neuron协议网关的北向应用插件开发
目录 概述 指令处理层开发 应用层开发 .open .close .init .uninit .start .stop .setting .request 插件设置文件 适配华为的思路 概述 最近研究了一段时间的Neuron协议网关,前面的博文也提到它虽然能够把数据发到华为的IoT平台上…...

【BUG】已解决:You are using pip version 10.0.1, however version 21.3.1 is available.
You are using pip version 10.0.1, however version 21.3.1 is available. 目录 You are using pip version 10.0.1, however version 21.3.1 is available. 【常见模块错误】 【解决方案】 欢迎来到英杰社区https://bbs.csdn.net/topics/617804998 欢迎来到我的主页&#…...

electron-builder打包vue2项目不显示element-ui图标
1、使用版本 vue ^2.6.14element-ui ^2.15.14vue-cli-plugin-electron-builder 2.1.1 2、解决办法 1) 如果是简单的图标可以使用图片代替(这种对于elementui组件的图标还是不会显示) 2)在vue.config.js配置 const { defineCon…...

controller层-请求格式为json-请求方法为get
前置条件 get请求映射,内容和PostMapping一致,需要请求参数更换为get数据 请求过程:用户请求--初始化DispatcherServlet及对接和分发用户请求--controller--service 用户请求:http://ip:port/user/getinfo 请求方法:ge…...

【Linux】网络通信基础:应用层协议、HTTP、序列化与会话管理
文章目录 前言1. 应用层自定义协议与序列化1.1 什么是应用层?1.2 再谈 "协议"1.3 序列化 和 反序列化 2. HTTP 协议3. 认识 URL(统一资源定位符)4. urlencode和urldecode5. HTTP 协议请求与响应格式5.1 HTTP 请求5.2 HTTP 响应 6. HTTP 的方法6.1 GET 方法…...

@NotNull、@NotEmpty 和 @NotBlank 区别
NotNull、NotEmpty 和 NotBlank 是 Java Bean Validation (JSR 380) 规范中定义的注解,通常用于验证对象的属性是否满足特定的条件。这些注解常用于后端验证,确保接收到的数据符合预期。 NotNull 用途:验证一个对象是否不为null。 注意&#…...

大模型应用—大模型赋能网络爬虫
大模型赋能网络爬虫 简单来说,网页抓取就是从网站抓取数据和内容,然后将这些数据保存为XML、Excel或SQL格式。除了用于生成潜在客户、监控竞争对手和市场研究外,网页抓取工具还可以用于自动化你的数据收集过程。 借助AI网页抓取工具,可以解决手动或纯基于代码的抓取工具的…...