我需要在我的项目中使用“我的世界”中的图片,但是有很多图片需要很长时间才能搜索和下载,而且我很懒。我的想法是使用一个模板在谷歌上搜索一张图片,例如:"minecraft: diamond_block“,图像必须在域名:"https://static.wikia.nocookie.net/”上,并且必须具有1: 1的纵横比,这些都是找到我想要的图像所需的要求。如何在NodeJS中实现这一点
发布于 2021-02-16 02:10:28
使用了这个
const GoogleImages = require('google-images');
const client = new GoogleImages('CSE KEY', 'API KEY');
const prefix = "minecraft "
let result = {}
client.search(prefix + 'ancient_debris', {})
.then(images => {
result = images.find((e) => {
if (e.url.match("https://static.wikia.nocookie.net/") === null) return false
if (e.url.match("latest") === null) return false
if (e.url.match("smart") !== null) return false
return e
})
console.log(result.url)
});https://stackoverflow.com/questions/66210072
复制相似问题