Skip to content

Commit 7fae0fb

Browse files
committed
Enhancements in Chrome options and closing webdriver
1 parent 814f146 commit 7fae0fb

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

src/excel_scraper.py

+12-1
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,10 @@ def configure_driver(self):
6969
options = webdriver.ChromeOptions()
7070
options.add_argument("--headless")
7171
options.add_argument("--no-sandbox")
72+
options.add_argument("--disable-gpu")
73+
options.add_argument("--disable-dev-shm-usage")
74+
options.add_argument("--disable-extensions")
75+
options.add_argument("--disable-plugins-discovery")
7276

7377
# If CHROME_DRIVER_PATH is set in .env, use it; else rely on PATH
7478
chrome_path = os.getenv("CHROME_DRIVER_PATH", "")
@@ -293,10 +297,17 @@ def save_file(self, url, content, new_hash):
293297

294298
async def close(self):
295299
"""Close Selenium and the async httpx session."""
296-
self.driver.quit()
300+
# Close the WebDriver
301+
if self.driver:
302+
self.driver.quit()
303+
self.driver = None
304+
logging.info("WebDriver closed.")
305+
306+
# Close the HTTPX session
297307
try:
298308
await self.session.aclose()
299309
except Exception as e:
300310
logging.error(f"❌ Error closing session: {e}")
301311
finally:
302312
logging.info("✅ Scraping complete")
313+

0 commit comments

Comments
 (0)