-
Notifications
You must be signed in to change notification settings - Fork 0
/
web driver.py
30 lines (22 loc) · 914 Bytes
/
web driver.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 selenium
from selenium import webdriver
import sys
# function to convert a list into string
def convert(s):
str1 = ""
return (str1.join(s))
# Assign the arguments passed to a variable search_string
search_string = sys.argv[1:]
# The argument passed to the program is accepted
# as list, it is needed to convert that into string
search_string = convert(search_string)
# This is done to structure the string
# into search url.(This can be ignored)
search_string = search_string.replace(' ', '+')
# Assigning the browser variable with chromedriver of Chrome.
# Any other browser and its respective webdriver
# like geckodriver for Mozilla Firefox can be used
browser = webdriver.Chrome('chromedriver')
for i in range(1):
matched_elements = browser.get("https://www.google.com/search?q=" +
search_string + "&start=" + str(i))