Selenium kill process to release mem, supervisor conf rotate log file

This commit is contained in:
Luciano Gervasoni
2025-07-28 11:16:15 +02:00
parent 54e41139bb
commit 1502f09e22
4 changed files with 49 additions and 8 deletions

View File

@@ -1,4 +1,4 @@
from utils import get_webdriver
from utils import get_webdriver, kill_process_tree
from selenium.webdriver.common.by import By
from urllib.parse import quote
import time
@@ -34,7 +34,7 @@ class SearchFetcher():
url = quote(url_unquoted, safe=":/?=&#")
# Initialize
driver = get_webdriver()
driver, service = get_webdriver()
# Load URL
driver.get(url)
time.sleep(2)
@@ -51,6 +51,9 @@ class SearchFetcher():
# Filter by URL host
urls = [u for u in urls if url_host in u]
driver.quit()
kill_process_tree(service.process.pid)
return urls
def _search_breitbart(self, search):
@@ -60,7 +63,7 @@ class SearchFetcher():
url = quote(url_unquoted, safe=":/?=&#")
# Initialize
driver = get_webdriver()
driver, service = get_webdriver()
# Load URL
driver.get(url)
time.sleep(4)
@@ -77,6 +80,9 @@ class SearchFetcher():
# Filter by URL host
urls = [u for u in urls if url_host in u]
driver.quit()
kill_process_tree(service.process.pid)
return urls
def _search_zerohedge(self, search):
@@ -86,7 +92,7 @@ class SearchFetcher():
url = quote(url_unquoted, safe=":/?=&#")
# Initialize
driver = get_webdriver()
driver, service = get_webdriver()
# Load URL
driver.get(url)
time.sleep(2)
@@ -103,4 +109,7 @@ class SearchFetcher():
# Filter by URL host
urls = [u for u in urls if url_host in u]
driver.quit()
kill_process_tree(service.process.pid)
return urls