Skip to content

Commit 501da47

Browse files
authored
Merge pull request #4 from Zubdata/adding_headless_mode
Adding headless mode option
2 parents 983da78 + b913dad commit 501da47

File tree

2 files changed

+15
-7
lines changed

2 files changed

+15
-7
lines changed

Google map scraper/scraper/frontend.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,12 @@ def __init__(self):
100100
)
101101
self.resetSettingsButton.place(x=20, y=590)
102102

103+
"""For healdess checkbox"""
104+
105+
self.healdessCheckBoxVar=tk.IntVar()
106+
self.healdessCheckBox= tk.Checkbutton(self.root,text="Headless mode",variable=self.healdessCheckBoxVar)
107+
self.healdessCheckBox.place(x=700,y=45)
108+
103109

104110
self.__replacingtext(
105111
"Welcome to Google Maps Scraper!\n\nLet's start scraping..."
@@ -151,6 +157,7 @@ def getinput(self):
151157

152158
self.searchQuery = self.searchQuery.lower()
153159
self.outputFormatValue = self.outputFormatValue.lower()
160+
self.headlessMode=self.healdessCheckBoxVar.get()
154161

155162
self.threadToStartBackend = threading.Thread(target=self.startscraping)
156163
self.threadToStartBackend.start()
@@ -170,6 +177,7 @@ def startscraping(self):
170177
self.outputFormatValue,
171178
self.messageshowing,
172179
self.outputfolderpath,
180+
healdessmode=self.headlessMode
173181
)
174182

175183
self.mainscraping()

Google map scraper/scraper/scraper.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -35,27 +35,23 @@ class Backend:
3535

3636
timeout = 60
3737

38-
def __init__(self, searchquery, outputformat, messageshowingfunc, outputpath):
38+
def __init__(self, searchquery, outputformat, messageshowingfunc, outputpath,healdessmode):
3939
"""
4040
params:
4141
4242
search query: it is the value that user will enter in search query entry
4343
outputformat: output format of file , selected by user
4444
messageshowingfunc: function refernece to function of frontend class to
4545
outputpath: directory path where file will be stored after scraping
46+
headlessmode: it's value can be 0 and 1, 0 means unchecked box and 1 means checked
4647
4748
"""
4849

4950

5051
self.searchquery = searchquery # search query that user will enter
5152
self.messageshowing = messageshowingfunc # it is a function used as api for transfering message form this backend to frontend
5253

53-
"""
54-
output path is location of folder where file will be stored after scraping.
55-
it will be asked When user will use this application for first time, after that
56-
user can change this path by clicking on the button "Reset path"
57-
"""
58-
54+
self.headlessMode=healdessmode
5955
self.datasaver = DataSaver(
6056
selectedpath=outputpath,
6157
outputformat=outputformat,
@@ -197,6 +193,10 @@ def mainscraping(self):
197193
"""Starting our browser"""
198194

199195
options = uc.ChromeOptions()
196+
197+
if self.headlessMode==1:
198+
options.headless=True
199+
200200
prefs = {"profile.managed_default_content_settings.images": 2}
201201
options.add_experimental_option("prefs", prefs)
202202

0 commit comments

Comments
 (0)