1.0.4 • Published 1 year ago

scrape-google-images v1.0.4

Weekly downloads
-
License
MIT
Repository
-
Last release
1 year ago

Scrape Google Images

A TypeScript library for scraping images from Google Images using Puppeteer.

npm GitHub

Installation

To use this library, you'll need Node.js installed on your machine. Then, you can install it via npm:

npm install scrape-google-images

Usage

import { scrapeImages } from 'scrape-google-images';

const query = 'cats';
const options = {
    limit: 10,
    imgSize: 'm',
    imgType: 'photo',
    imgColor: 'color',
    imgar: 'xw',
    fileType: 'jpg',
    safe: false,
    siteSearch: '',
    rights: '',
    metadata: true,
    imgData: false,
    engine: 'pupeeteer'
};

const images = await scrapeImages(query, options);

Options

The pick function accepts an optional options object with the following properties:

OptionTypeDefaultDescription
limitnumber10Maximum number of images to retrieve. (max: 100)
imgSizestring''Filter images by size (e.g., 'l''m''i''qsvga''vga''svga''xga').
imgTypestring''Filter images by type (e.g., 'clipart''face''lineart''stock''photo').
imgColorstring''Filter images by color (e.g., 'mono''gray''color''trans').
imgarstring''Filter images by aspect ratio (e.g., 't', 's', 'w', 'xw')
fileTypestring''Filter images by file type (e.g., 'jpg''gif''png''bmp''svg''webp').
safebooleanfalseEnable safe search filter.
siteSearchstring''Search for images from a specific website.
rightsstring''Filter images by usage rights (e.g., 'cl' for creative commons, 'ol' for other).
randombooleanfalseRandomize the order of search results.
metadatabooleantrueInclude image metadata in the results.
imgDatabooleanfalseInclude base64 image data in the results.
enginestringpupeeteerLib used to scrap Google Images Data. pupeeteer or cheerio

Result

The pick function returns a Promise that resolves to an array of PickResult objects, each containing the following properties:

PropertyTypeDescription
srcstringThe URL of the image.
imgDatastringThe base64 image data (if imgData is true).
descriptionstringThe image description or alt text.
sourcestringThe URL of the source website.
metadataobjectThe image metadata (if metadata is true).

\ The metadata object has the following properties:

PropertyTypeDescription
widthnumberThe width of the image.
heightnumberThe height of the image.
formatsharp.FormatEnumThe format of the image.

Licence

This library is licensed under the MIT License. See the LICENSE file for more information.

1.0.2-alpha.30

1 year ago

1.0.2-alpha.11

1 year ago

1.0.2-alpha.12

1 year ago

1.0.2-alpha.10

1 year ago

1.0.2-alpha.16

1 year ago

1.0.2-alpha.13

1 year ago

1.0.2-alpha.14

1 year ago

1.0.2-alpha.19

1 year ago

1.0.4

1 year ago

1.0.2-alpha.17

1 year ago

1.0.3

1 year ago

1.0.2-alpha.18

1 year ago

1.0.3-alpha.1

1 year ago

1.0.2-alpha.22

1 year ago

1.0.2-alpha.23

1 year ago

1.0.2-alpha.20

1 year ago

1.0.2-alpha.26

1 year ago

1.0.2-alpha.27

1 year ago

1.0.2-beta.10

1 year ago

1.0.2-alpha.24

1 year ago

1.0.2-alpha.25

1 year ago

1.0.2-alpha.28

1 year ago

1.0.2-alpha.29

1 year ago

1.0.2-beta.6

1 year ago

1.0.2-beta.7

1 year ago

1.0.2-beta.8

1 year ago

1.0.2-beta.9

1 year ago

1.0.2

1 year ago

1.0.0

1 year ago

1.0.1-beta.2

1 year ago

1.0.1-beta.0

1 year ago

1.0.1-beta.5

1 year ago

1.0.1-beta.4

1 year ago

1.0.1-beta.3

1 year ago

0.0.3

1 year ago

0.0.3-beta.0

1 year ago

0.0.3-beta.1

1 year ago

0.0.2

1 year ago

0.0.1

1 year ago

0.0.0

1 year ago