-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.py
30 lines (23 loc) · 905 Bytes
/
main.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
import sys
import argparse
from scrapper import Scrapper
from istockphoto import IStockSearch
def parser():
pars = argparse.ArgumentParser(description='Stock image scrap tool')
pars.add_argument('--search-engine', type=str, default='istockphoto')
pars.add_argument('--search-query', type=str, nargs='+', required=True)
pars.add_argument('--total-images', type=int, required=True)
arg = pars.parse_args()
arg.search_query = " ".join(arg.search_query)
return arg
if __name__ == '__main__':
arg = parser()
if arg.search_engine == 'istockphoto':
search_engine = IStockSearch()
else:
search_engine = IStockSearch()
# TODO: Will be fixed when new engines added
search_engine.set_search_param(search_query=arg.search_query)
scrap = Scrapper(search_engine=search_engine, total_image=arg.total_images)
scrap.download()
sys.exit(0)