< All posts

Dec. 11, 2019, 4:24 p.m.

Python, Wget, Image downloader for Searx instances

This is a python script for scraping images from a Searx instance, you just need to initially search for an image and download the JSON file.

Please modify the file paths json_file='/home/user/SRC.json' and '/home/user/SRC.sh'.

#!/usr/bin/python

#    Date Created: 12-17-2017
#    Image Downloader Searx
#    Copyright (C) 2017-2018 sora
#
#    This program is free software: you can redistribute it and/or modify
#    it under the terms of the GNU General Public License as published by
#    the Free Software Foundation, either version 3 of the License, or
#    (at your option) any later version.
#
#    This program is distributed in the hope that it will be useful,
#    but WITHOUT ANY WARRANTY; without even the implied warranty of
#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
#    GNU General Public License for more details.
#
#    You should have received a copy of the GNU General Public License
#    along with this program.  If not, see .
#
#    USAGE:
#    Requires: Python, Wget, Browser
#    Open a searx instance, search for image, download the json result, set json path, set python bin path and execute this script using bash. eg. python ./thisscript.py

import os,json,subprocess,time,datetime
from pprint import pprint

json_file='/home/user/SRC.json'
json_data=open(json_file)
j = json.load(json_data)
json_data.close()

file = open('/home/user/SRC.sh','w')
for i in range(0,1132): #img_src SET 1132 based on JSON content
 try:
    print(str(i)+ ":" + j["results"][i]["img_src"])
    file.write('wget -c "' + str(j["results"][i]["img_src"]) + '"' + "\n" )
 except KeyError:
     continue
 except IndexError:
     continue
file.close
os.system("chown +x /home/user/SRC.sh")
os.system("bash /home/user/SRC.sh")