Semihal
9/28/2019 - 2:49 PM

Scrape Google and Yandex images

import uuid
from pathlib import Path
from fastai.vision import download_images

path = Path('path_to_folder_with_csv')
files = path.iterdir()
for i, csv_path enumerate(files):
    uuid = str(uuid.uuid4())
    if not csv_path.is_dir():
        download_images(path / csv_path, path / f'scrapped_{uuid}')
// execute in google / etc. browser console
urls = Array.from(document.querySelectorAll('.rg_di .rg_meta')).map(el=>JSON.parse(el.textContent).ou);
window.open('data:text/csv;charset=utf-8,' + escape(urls.join('\n')));
// execute in google / etc. browser console
urls = $x("//div[contains(@class, 'serp-item')]/@data-bem").map(el => JSON.parse(el.textContent)['serp-item'].img_href)
window.open('data:text/csv;charset=utf-8,' + escape(urls.join('\n')));