-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcontroller.py
More file actions
27 lines (21 loc) · 811 Bytes
/
controller.py
File metadata and controls
27 lines (21 loc) · 811 Bytes
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
import ImageDownloader as Id
from selenium import webdriver
from selenium.webdriver.common.by import By
PAGE_URL = "https://www.google.com/imghp?hl=en"
def getInput():
searchField = input("What images would you like to see?: ")
maxImages = int(input("How many images do you want?: "))
return searchField, maxImages
def googleSearch(userInput):
searchField, maxImages = userInput[0], userInput[1]
PATH = "/Users/advikmehta/Desktop/PycharmProjects/ImageScraperBot/chromedriver"
wd = webdriver.Chrome(PATH)
wd.get(PAGE_URL)
# finding search box and searching with keyword
ele = wd.find_element(By.NAME, "q")
ele.send_keys(searchField)
ele.submit()
# downloading images
Id.downloadImages(wd, 1, maxImages, searchField)
wd.quit()
googleSearch(getInput())