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")
ΡΡΠΎΠ±Ρ Π½Π°ΡΠ°ΡΡ Π²Π°ΠΌ ΠΏΠΎΠ½Π°Π΄ΠΎΠ±ΠΈΡΡΡ ΠΎΠ±ΡΠ΅ΠΊΡ Ρ ΠΏΠ°ΡΠ°ΠΌΠ΅ΡΡΠ°ΠΌΠΈ ΠΏΠΎΠΈΡΠΊΠ°
ΠΎΠ±ΡΠ·Π°ΡΠ΅Π»ΡΠ½ΡΠ΅ ΠΏΠ°ΡΠ°ΠΌΠ΅ΡΡΡ
ΠΊΠ»ΡΡ | Π·Π½Π°ΡΠ΅Π½ΠΈΠ΅ | ΠΈΠ½ΡΠΎΡΠΌΠ°ΡΠΈΡ |
---|---|---|
text | string | ΠΈΡΠΏΠΎΠ»ΡΠ·ΡΠ΅ΡΡΡ Π΄Π»Ρ ΠΏΠΎΠΈΡΠΊΠ° ΠΊΠ°ΡΡΠΈΠ½ΠΊΠΈ ΠΏΠΎ ΡΠ΅ΠΊΡΡΡ |
url | string | ΠΈΡΠΏΠΎΠ»ΡΠ·ΡΠ΅ΡΡΡ Π΄Π»Ρ ΠΏΠΎΠΈΡΠΊΠ° ΠΏΠΎΡ ΠΎΠΆΠ΅ΠΉ ΠΊΠ°ΡΡΠΈΠ½ΠΊΠΈ ΠΈΠ»ΠΈ ΠΎΡΠΈΠ³ΠΈΠ½Π°Π»Π° |
Π½Π΅ ΠΎΠ±ΡΠ·Π°ΡΠ΅Π»ΡΠ½ΡΠ΅ ΠΏΠ°ΡΠ°ΠΌΠ΅ΡΡΡ
ΠΊΠ»ΡΡ | Π·Π½Π°ΡΠ΅Π½ΠΈΠ΅ | Π·Π½Π°ΡΠ΅Π½ΠΈΠ΅ ΠΏΠΎ-ΡΠΌΠΎΠ»ΡΠ°Π½ΠΈΡ | ΠΈΠ½ΡΠΎΡΠΌΠ°ΡΠΈΡ |
---|---|---|---|
isize | string | [large, medium, small, eq, wallpaper, eq] | ΠΈΡΠΏΠΎΠ»ΡΠ·ΡΠ΅ΡΡΡ Π΄Π»Ρ ΠΏΠΎΠΈΡΠΊΠ° ΠΊΠ°ΡΡΠΈΠ½ΠΊΠΈ ΠΎΠΏΡΠ΅Π΄Π΅Π»Π΅Π½Π½ΠΎΠ³ΠΎ ΡΠ°Π·ΠΌΠ΅ΡΠ° |
iw | int | * | ΠΈΡΠΏΠΎΠ»ΡΠ·ΡΠ΅ΡΡΡ Π΄Π»Ρ ΠΏΠΎΠΈΡΠΊΠ° ΠΊΠ°ΡΡΠΈΠ½ΠΊΠΈ ΡΠΎΡΠ½ΠΎΠ³ΠΎ ΡΠ°Π·ΠΌΠ΅ΡΠ°, ΠΏΡΠΈ ΡΡΠΎΠΌ Π·Π½Π°ΡΠ΅Π½ΠΈΠ΅ ΠΊΠ»ΡΡΠ° "isize" Π΄ΠΎΠ»ΠΆΠ½ΠΎ Π±ΡΡΡ "eq" |
ih | int | * | ΠΈΡΠΏΠΎΠ»ΡΠ·ΡΠ΅ΡΡΡ Π΄Π»Ρ ΠΏΠΎΠΈΡΠΊΠ° ΠΊΠ°ΡΡΠΈΠ½ΠΊΠΈ ΡΠΎΡΠ½ΠΎΠ³ΠΎ ΡΠ°Π·ΠΌΠ΅ΡΠ°, ΠΏΡΠΈ ΡΡΠΎΠΌ Π·Π½Π°ΡΠ΅Π½ΠΈΠ΅ ΠΊΠ»ΡΡΠ° "isize" Π΄ΠΎΠ»ΠΆΠ½ΠΎ Π±ΡΡΡ "eq" |
iorient | string | [square, horizontal, vertical] | ΠΈΡΠΏΠΎΠ»ΡΠ·ΡΠ΅ΡΡΡ Π΄Π»Ρ ΠΏΠΎΠΈΡΠΊΠ° ΠΊΠ°ΡΡΠΈΠ½ΠΊΠΈ ΠΎΠΏΡΠ΅Π΄Π΅Π»Π΅Π½Π½ΠΎΠΉ ΠΎΡΠΈΠ΅Π½ΡΠ°ΡΠΈΠΈ |
type | string | [photo, clipart, lineart, face, demotivator] | ΠΈΡΠΏΠΎΠ»ΡΠ·ΡΠ΅ΡΡΡ Π΄Π»Ρ ΠΏΠΎΠΈΡΠΊΠ° ΠΊΠ°ΡΡΠΈΠ½ΠΊΠΈ ΠΎΠΏΡΠ΅Π΄Π΅Π»Π΅Π½Π½ΠΎΠ³ΠΎ ΡΠΈΠΏΠ° |
icolor | string | [orange, color, gray, red, orange, yellow, cyan, green, blue] | ΠΈΡΠΏΠΎΠ»ΡΠ·ΡΠ΅ΡΡΡ Π΄Π»Ρ ΠΏΠΎΠΈΡΠΊΠ° ΠΊΠ°ΡΡΠΈΠ½ΠΊΠΈ ΠΎΠΏΡΠ΅Π΄Π΅Π»Π΅Π½Π½ΠΎΠΉ ΡΠ²Π΅ΡΠΎΠ²ΠΎΠΉ Π³Π°ΠΌΠΌΡ |
itype | string | [png, jpg, jpeg, gif] | ΠΈΡΠΏΠΎΠ»ΡΠ·ΡΠ΅ΡΡΡ Π΄Π»Ρ ΠΏΠΎΠΈΡΠΊΠ° ΠΊΠ°ΡΡΠΈΠ½ΠΊΠΈ ΠΎΠΏΡΠ΅Π΄Π΅Π»Π΅Π½Π½ΠΎΠ³ΠΎ ΡΠΈΠΏΠ° ΡΠ°ΠΉΠ»ΠΎΠ² |
page | int | 0-49 | ΠΈΡΠΏΠΎΠ»ΡΠ·ΡΠ΅ΡΡΡ Π΄Π»Ρ ΠΏΠΎΠΈΡΠΊΠ° ΠΊΠ°ΡΡΠΈΠ½ΠΊΠΈ Π½Π° ΡΠΎΡΠ½ΠΎΠΉ ΠΏΠΎΠ·ΠΈΡΠΈΠΈ (ΡΠΌΠ΅ΡΠ΅Π½ΠΈΠΈ) |
count | int | 1-30 | Π½Π΅ΠΎΠ±Ρ ΠΎΠ΄ΠΈΠΌΠΎΠ΅ ΠΊΠΎΠ»ΠΈΡΠ΅ΡΡΠ²ΠΎ ΠΊΠ°ΡΡΠΈΠ½ΠΎΠΊ ΠΊΠΎΡΠΎΡΠΎΠ΅ Π½ΡΠΆΠ½ΠΎ Π²Π΅ΡΠ½ΡΡΡ |
comm | int | [*, 1] | ΠΈΡΠΏΠΎΠ»ΡΠ·ΡΠ΅ΡΡΡ Π΄Π»Ρ ΠΏΠΎΠΈΡΠΊΠ° ΠΊΠ°ΡΡΠΈΠ½ΠΊΠΈ Π² ΠΊΠ°ΡΠ΅ΡΡΠ²Π΅ ΡΠΎΠ²Π°ΡΠ° |
recent | string | [*, D7] | ΠΈΡΠΏΠΎΠ»ΡΠ·ΡΠ΅ΡΡΡ Π΄Π»Ρ ΠΏΠΎΠΈΡΠΊΠ° Π±ΠΎΠ»Π΅Π΅ ΡΠ²Π΅ΠΆΠΈΡ ΠΊΠ°ΡΡΠΈΠ½ΠΎΠΊ |
wp | string | [*, wh16x9_1366x768] | ΠΈΡΠΏΠΎΠ»ΡΠ·ΡΠ΅ΡΡΡ Π΄Π»Ρ ΠΏΠΎΠΈΡΠΊΠ° ΠΊΠ°ΡΡΠΈΠ½ΠΎΠΊ Π΄Π»Ρ ΡΠ°Π±ΠΎΡΠ΅Π³ΠΎ ΡΡΠΎΠ»Π° |
site | string | * | ΠΈΡΠΏΠΎΠ»ΡΠ·ΡΠ΅ΡΡΡ Π΄Π»Ρ ΠΏΠΎΠΈΡΠΊΠ° ΠΊΠ°ΡΡΠΈΠ½ΠΊΠΈ Π½Π° ΠΎΠΏΡΠ΅Π΄Π΅Π»Π΅Π½Π½ΠΎΠΌ ΡΠ°ΠΉΡΠ΅ |
family | int | [0,1,2] | ΠΈΡΠΏΠΎΠ»ΡΠ·ΡΠ΅ΡΡΡ Π΄Π»Ρ ΡΠ΅Π½Π·ΡΡΠΈΡΠΎΠ²Π°Π½ΠΈΡ ΠΏΠΎΠΈΡΠΊΠ° 0 - Π±Π΅Π· ΡΠ΅Π½Π·ΡΡΡ 1 - ΡΠΌΠ΅ΡΠ΅Π½Π½ΡΠΉ 2 - ΡΠ΅ΠΌΠ΅ΠΉΠ½ΡΠΉ ΠΏΠΎΠΈΡΠΊ |
Π°ΡΠΈΠ½Ρ ΡΠΎΠ½Π½Π°Ρ ΡΡΠ½ΠΊΡΠΈΡ
const yapic = require("yandex-pictures")
yapic.getImage({
text: "JSusDev",
count: 2
}, (err, res) => {
// ΠΎΠ±ΡΠ°Π±ΠΎΡΠΊΠ° ΠΎΡΠΈΠ±ΠΎΠΊ ΠΊΠ°ΠΊ Π²Π΅Π·Π΄Π΅...
console.log(res)
/* ΡΡΡ Π²Π΅ΡΠ½Π΅ΡΡΡ ΠΌΠ°ΡΡΠΈΠ² ΠΊΠ°ΡΡΠΈΠ½ΠΎΠΊ
Π΅ΡΠ»ΠΈ ΠΎΠ½ΠΈ Π΅ΡΠ»ΠΈ Π΅ΡΡΡ ΠΈΠ»ΠΈ
ΠΏΡΡΡΠΎΠΉ ΠΌΠ°ΡΡΠΈΠ² */
})
Π°ΡΠΈΠ½Ρ ΡΠΎΠ½Π½Π°Ρ (promise) ΡΡΠ½ΠΊΡΠΈΡ
const yapic = require("yandex-pictures")
yapic.getImage({
text: "JSusDev",
count: 2
}).then(console.log)
ΡΠΈΠ½Ρ ΡΠΎΠ½Π½Π°Ρ ΡΡΠ½ΠΊΡΠΈΡ
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 - library for pulling Ynadex images
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.
to begin, install the package yandex-pictures
$ npm install yandex-pictures -s
connect the module
const yapic = require("yandex-pictures")
and so to begin the desired object with the search parameters of the picture
required parameter
options | types | info |
---|---|---|
text | string | search for string |
url | string | search for a similar picture |
optional parameter
options | types | default | info |
---|---|---|---|
isize | string | [large, medium, small, eq, wallpaper, eq] | used to search for images of a certain size " eq "used with" iw " and " ih" |
iw | int | * | is used to search for images of a certain size in the case when i size the "eq" |
ih | int | * | is used to search for images of a certain size in the case when i size the "eq" |
iorient | string | [square, horizontal, vertical] | used to search for an image of a specific orientation |
type | string | [photo, clipart, lineart, face, demotivator] | used to search for a certain type of picture |
icolor | string | [orange, color, gray, red, orange, yellow, cyan, green, blue] | used to search for color pictures |
itype | string | [png, jpg, jpeg, gif] | is used to search for images of a specific file type |
page | int | 0-49 | shift the search page |
count | int | 1-30 | the maximum number of images to return |
comm | int | [*, 1] | is used to search for pictures of product |
recent | string | [*, D7] | used to find a more recent picture |
wp | string | [*, wh16x9_1366x768] | is used to search images for your desktop |
site | string | * | used to search for images on the specified site |
family | int | [1,2,3] | allows you to configure search security used to censor search 0-uncensored 1-moderate 2-family search |
asynchronous function
const yapic = require("yandex-pictures")
yapic.getImage({
text: "JSusDev",
count: 2
}, (err, res) => {
console.log(res)
})
asynchronous (promise) function
const yapic = require("yandex-pictures")
yapic.getImage({
text: "JSusDev",
count: 2
}).then(console.log)
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)
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)
})
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.