提问人:Ancient Bison 提问时间:10/7/2023 更新时间:10/7/2023 访问量:27
Google CSE API 返回同一图像的多个变体
Google CSE API returning multiple variations of same image
问:
当向谷歌 CSE API 发送请求时,我最终得到了同一张图片的多个变体。
const pagesToDownload = 1;
let pagesDownloaded = 0;
(async () => {
const { google } = require('googleapis');
const search = google.customsearch('v1');
const query = 'pasta';
let erroring = false;
const nextPage = () => {
if (pagesDownloaded != pagesToDownload && !erroring) {
search.cse.list({
q: query,
auth: process.env['CX_KEY'],
cx: "410a480db45d74a71",
searchType: 'image',
start: 1 + (pagesDownloaded * 10),
fileType: "jpeg,jpg,png,gif,ico,bmp"
}, async (err, res) => {
if (err) {
console.log("REQUEST FAILED: " + err);
erroring = true;
} else {
console.log(res);
await downloadImagesFromSearchResult(res);
pagesDownloaded++;
nextPage();
}
});
} else {
console.log("Successfully downloaded %d images", pagesDownloaded * 10);
}
}
nextPage();
})();
我试过打开和关闭重复过滤器,但都没有区别。下面是同一请求中返回的三张图片的示例:
我该如何删除重复项?
答: 暂无答案
评论