首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >在NodeJS中按模式搜索图像

在NodeJS中按模式搜索图像
EN

Stack Overflow用户
提问于 2021-02-15 22:43:22
回答 1查看 29关注 0票数 0

我需要在我的项目中使用“我的世界”中的图片,但是有很多图片需要很长时间才能搜索和下载,而且我很懒。我的想法是使用一个模板在谷歌上搜索一张图片,例如:"minecraft: diamond_block“,图像必须在域名:"https://static.wikia.nocookie.net/”上,并且必须具有1: 1的纵横比,这些都是找到我想要的图像所需的要求。如何在NodeJS中实现这一点

EN

回答 1

Stack Overflow用户

发布于 2021-02-16 02:10:28

使用了这个

代码语言:javascript
复制
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)
  });
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/66210072

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档