Skip to content

Commit ce1e5f7

Browse files
committed
Make "Headless" as a field in conf.json
1 parent d813c76 commit ce1e5f7

File tree

3 files changed

+8
-4
lines changed

3 files changed

+8
-4
lines changed

LeetCode_AC_Code_Crawler.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -192,14 +192,16 @@ def suffix_conversion(suff="cpp"):
192192
password = conf["Password"]
193193
outputDir = conf["OutputDir"]
194194
driverPath = conf["ChromedriverPath"]
195+
headless = conf["Headless"]
195196

196197
if not os.path.isdir(outputDir):
197198
print("Output directory not found")
198199
sys.exit(1)
199200

200201
chrome_options = Options()
201-
chrome_options.add_argument('--headless')
202-
chrome_options.add_argument('--log-level=3')
202+
if headless == True:
203+
chrome_options.add_argument('--headless')
204+
chrome_options.add_argument('--log-level=3')
203205
driver = webdriver.Chrome(driverPath, chrome_options=chrome_options)
204206

205207
login()

README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,8 @@ You have to modify variables in `conf.json`.
2222
"Username": "YOUR_USERNAME",
2323
"Password": "YOUR_PASSWORD",
2424
"OutputDir": "THE_ABSOLUTE_PATH_THAT_YOU_WANT_TO_SAVE_FILES",
25-
"ChromedriverPath": "THE_ABSOLUTE_PATH_OF_CHROMEDRIVER"
25+
"ChromedriverPath": "THE_ABSOLUTE_PATH_OF_CHROMEDRIVER",
26+
"Headless": true
2627
}
2728
```
2829

conf.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,6 @@
22
"Username": "YOUR_USERNAME",
33
"Password": "YOUR_PASSWORD",
44
"OutputDir": "THE_ABSOLUTE_PATH_THAT_YOU_WANT_TO_SAVE_FILES",
5-
"ChromedriverPath": "THE_ABSOLUTE_PATH_OF_CHROMEDRIVER"
5+
"ChromedriverPath": "THE_ABSOLUTE_PATH_OF_CHROMEDRIVER",
6+
"Headless": true
67
}

0 commit comments

Comments
 (0)