1.4.88 • Published 6 years ago

yandex-pictures v1.4.88

Weekly downloads
30
License
ISC
Repository
github
Last release
6 years ago

enter image description here

lang: ru en

yandex-pictures

yandex-pictures - Оболочка внутреннего программного интерфейса Yandex Image

Почему ?

поскольку у Яндекса нет API для получения общедоступных изображений (03.03.2018), то вчера утром я еще раз убедился, что его не существует, а точнее он есть , но только "на бумаге" Yandex pictures api , я решил разработать его на основе внутреннего API Яндекс Картинок.

С чего начать

Установим npm модуль yandex-pictures

$ npm install yandex-pictures -s

Примеры

подключение модуля

const yapic = require("yandex-pictures")

чтобы начать вам понадобится объект с параметрами поиска

Объект

обязательные параметры

ключзначениеинформация
textstringиспользуется для поиска картинки по тексту
urlstringиспользуется для поиска похожей картинки или оригинала

не обязательные параметры

ключзначениезначение по-умолчаниюинформация
isizestringlarge, medium, small, eq, wallpaper, eqиспользуется для поиска картинки определенного размера
iwint*используется для поиска картинки точного размера, при этом значение ключа "isize" должно быть "eq"
ihint*используется для поиска картинки точного размера, при этом значение ключа "isize" должно быть "eq"
iorientstringsquare, horizontal, verticalиспользуется для поиска картинки определенной ориентации
typestringphoto, clipart, lineart, face, demotivatorиспользуется для поиска картинки определенного типа
icolorstringorange, color, gray, red, orange, yellow, cyan, green, blueиспользуется для поиска картинки определенной цветовой гаммы
itypestringpng, jpg, jpeg, gifиспользуется для поиска картинки определенного типа файлов
pageint0используется для поиска картинки на точной позиции (смещении)
countint30необходимое количество картинок которое нужно вернуть (пробовал 610 норм)
commint*, 1используется для поиска картинки в качестве товара
recentstring*, D7используется для поиска более свежих картинок
wpstring*, wh16x9_1366x768используется для поиска картинок для рабочего стола
sitestring*используется для поиска картинки на определенном сайте
familystring0,1,2используется для цензурирования поиска 0 - без цензуры 1 - умеренный 2 - семейный поиск

|

Объект используется в следующих функциях

асинхронная функция

const yapic = require("yandex-pictures")

yapic.getImage({
    
    text: "JSusDev",
    count: 2

}, (err, res) => {
    // обработка ошибок как везде...
    
    console.log(res) 
    
    /* тут вернется массив картинок
       если они если есть или 
       пустой массив */

}) 

синхронная функция

const yapic = require("yandex-pictures")

const images = yapic.getImageSync({

    text: "JSusDev",
    count: 2

})

console.log(images) 

/* тут вернется массив картинок
   если они если есть или 
   пустой массив */

вы можете передать следующим параметром в каждую из функций объект с заголовками и тд

асинхронная функция

const yapic = require("yandex-pictures")

yapic.getImage({
    
    text: "JSusDev",
    count: 2

}, {/* ... обратитесь к библиотеке 'request' чтобы уточнить структуру объекта с настроками запроса ... */}, (err, res) => {

    console.log(res)

}) 

синхронная функция

const yapic = require("yandex-pictures")

const images = yapic.getImageSync({

    text: "JSusDev",
    count: 2

}, {/* ... обратитесь к библиотеке 'sync-request' чтобы уточнить структуру объекта с настроками запроса ... */})

console.log(images)

Еще немного примеров

асинхронная функция для поиска подобной картинки

const yapic = require("yandex-pictures")

yapic.getImage({

    url: "https://static1.tgstat.com/public/images/channels/_0/82/822ecac8ab696703149dc7bb7ce2474d.jpg"

}, (err, res) => {

    console.log(res)
    
    /* тут вернется массив картинок
       если они если есть или 
       пустой массив */
       
})

асинхронная функция для поиска картинки по параметрам объекта

const yapic = require("yandex-pictures")

yapic.getImage({

    text: "гражданская оборона",
    icolor: "gray",
    isize: "eq",
    iw: 800,
    ih: 600,
    count: 3

}, (err, res) => {

    console.log(res)
    
    /* тут вернется массив картинок
       если они если есть или 
       пустой массив */

})

Контакты

Мой Телегам: @JSusDev, канал https://t.me/Jsusdevs

если у вас есть какие-либо вопросы и/или предложения, пожалуйста, напишите мне в телеграмме, если вы найдете ошибки я буду очень благодарен, также дайте мне знать

yandex-pictures by JSus

yandex-pictures

yandex-pictures - library for pulling Ynadex images

Why?

since Yandex does not have an API to get public images (03.03.2018), yesterday morning I was once again convinced that it does not exist, or rather it is, but only "on paper" Yandex pictures api , I decided to develop it on the basis of the internal API Yandex images.

Get started

to begin, install the package yandex-pictures

$ npm install yandex-pictures -s

Examples

connect the module

const yapic = require("yandex-pictures")

and so to begin the desired object with the search parameters of the picture

Object

required parameter

optionstypesinfo
textstringsearch for string
urlstringsearch for a similar picture

optional parameter

optionstypesdefaultinfo
isizestringlarge, medium, small, eq, wallpaper, eqused to search for images of a certain size " eq "used with" iw " and " ih"
iwint*is used to search for images of a certain size in the case when i size the "eq"
ihint*is used to search for images of a certain size in the case when i size the "eq"
iorientstringsquare, horizontal, verticalused to search for an image of a specific orientation
typestringphoto, clipart, lineart, face, demotivatorused to search for a certain type of picture
icolorstringorange, color, gray, red, orange, yellow, cyan, green, blueused to search for color pictures
itypestringpng, jpg, jpeg, gifis used to search for images of a specific file type
pageint0shift the search page
countint30the maximum number of images to return
commint*, 1is used to search for pictures of product
recentstring*, D7used to find a more recent picture
wpstring*, wh16x9_1366x768is used to search images for your desktop
sitestring*used to search for images on the specified site
familystring1,2,3allows you to configure search security

The object is used in the following functions

asynchronous function

const yapic = require("yandex-pictures")

yapic.getImage({
    
    text: "JSusDev",
    count: 2

}, (err, res) => {

    console.log(res)

}) 

synchronous function

const yapic = require("yandex-pictures")

const images = yapic.getImageSync({

    text: "JSusDev",
    count: 2

})

console.log(images)

for these functions, you can pass an optional header parameter and other crap

asynchronous function

const yapic = require("yandex-pictures")

yapic.getImage({
    
    text: "JSusDev",
    count: 2

}, {/* ... options request from lib 'request' ... */}, (err, res) => {

    console.log(res)

}) 

synchronous function

const yapic = require("yandex-pictures")

const images = yapic.getImageSync({

    text: "JSusDev",
    count: 2

}, {/* ... options request from lib 'sync-request' ... */})

console.log(images)

A few more examples

asynchronous search function for similar images

const yapic = require("yandex-pictures")

yapic.getImage({

    url: "https://static1.tgstat.com/public/images/channels/_0/82/822ecac8ab696703149dc7bb7ce2474d.jpg"

}, (err, res) => {

    console.log(res)

})

asynchronous function text search with other parameters

const yapic = require("yandex-pictures")

yapic.getImage({

    text: "гражданская оборона",
    icolor: "gray",
    isize: "eq",
    iw: 800,
    ih: 600,
    count: 3

}, (err, res) => {

    console.log(res)

})

Contacts

my telegram: @JSusDev, channel https://t.me/Jsusdevs

if you have any questions and suggestions please email me in telegram if you find bugs I will be very grateful if you also let me know

yandex-pictures by JSus
1.4.88

6 years ago

0.14.89

6 years ago

0.14.88

6 years ago

2.2.9

6 years ago