Skip to content

Commit

Permalink
Force selenium to always use preinstalled driver (#17)
Browse files Browse the repository at this point in the history
  • Loading branch information
jsetton authored Sep 16, 2023
1 parent 19b4789 commit 8fd6cf8
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
10 changes: 9 additions & 1 deletion craigslist-renew.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import atexit
import logging
import re
import shutil
import sys
from argparse import ArgumentParser, FileType
from bs4 import BeautifulSoup
Expand Down Expand Up @@ -193,12 +194,19 @@ def init_webdriver():
options.add_argument(f'user-agent={UserAgent().chrome}')

if not config.get('webdriver'):
service = webdriver.ChromeService(
executable_path=shutil.which('chromedriver')
)
driver = webdriver.Chrome(
service=service,
options=options
)
elif not config['webdriver'].startswith('http'):
service = webdriver.ChromeService(
executable_path=config['webdriver']
)
driver = webdriver.Chrome(
executable_path=config['webdriver'],
service=service,
options=options
)
else:
Expand Down
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@ beautifulsoup4==4.12.2
fake-useragent==1.2.1
html5lib==1.1
PyYAML==6.0.1
selenium==4.11.2
selenium==4.12.0

0 comments on commit 8fd6cf8

Please sign in to comment.