diff --git a/core/selenium.py b/core/selenium.py index 14c4ba9..c1f9154 100644 --- a/core/selenium.py +++ b/core/selenium.py @@ -1,5 +1,6 @@ from time import sleep +from django.conf import settings from selenium import webdriver from selenium.webdriver.common.by import By @@ -9,6 +10,10 @@ def update_linkedin_cookies_with_selenium(): for account in LinkedinAccount.objects.filter(is_active=True): options = webdriver.FirefoxOptions() + + if settings.SELENIUM_HEADLESS: + options.add_argument("--headless") + profile = webdriver.FirefoxProfile() profile.set_preference("network.proxy.type", 0) options.profile = profile @@ -34,6 +39,8 @@ def update_linkedin_cookies_with_selenium(): driver.implicitly_wait(10) if "feed" not in driver.current_url: + print() + print(driver.current_url) input( "Manual login required. Check the browser and then press any key to continue: " ) diff --git a/relohub/settings.py b/relohub/settings.py index c57414f..5ad7cf5 100644 --- a/relohub/settings.py +++ b/relohub/settings.py @@ -123,6 +123,25 @@ def env_list(key): "RELAY_CONNECTION_MAX_LIMIT": 100, } +LINKEDIN_JOB_DESCRIPTION_KEYWORDS = [ + "relocation", + "relo", + "relocate", + "visa", +] + +LINKEDIN_JOB_DESCRIPTION_KEYWORD_COMPLEMENTS = [ + "costs", + "allowance", + "bonus", + "coverage", + "package", + "sponsorship", + "support", + "assistance", + "assistant", + "cover", +] # Internationalization LANGUAGE_CODE = env_default("LANGUAGE_CODE", "en-us") @@ -130,6 +149,9 @@ def env_list(key): USE_I18N = True USE_TZ = True +# Selenium +SELENIUM_HEADLESS = env_literal("SELENIUM_HEADLESS") + # Static files (CSS, JavaScript, Images) STATIC_URL = "/static/" STATIC_ROOT = BASE_DIR / "static" @@ -144,23 +166,3 @@ def env_list(key): DATA_UPLOAD_MAX_NUMBER_FIELDS = None AUTH_USER_MODEL = "user.User" - -LINKEDIN_JOB_DESCRIPTION_KEYWORDS = [ - "relocation", - "relo", - "relocate", - "visa", -] - -LINKEDIN_JOB_DESCRIPTION_KEYWORD_COMPLEMENTS = [ - "costs", - "allowance", - "bonus", - "coverage", - "package", - "sponsorship", - "support", - "assistance", - "assistant", - "cover", -] diff --git a/sample.env b/sample.env index 143f55e..cabdda8 100644 --- a/sample.env +++ b/sample.env @@ -21,4 +21,6 @@ REDIS_BIND_PORT= LANGUAGE_CODE=en-US TIME_ZONE=Asia/Tehran -CELERY_BROKER_URL=redis:// \ No newline at end of file +CELERY_BROKER_URL=redis:// + +SELENIUM_HEADLESS=True \ No newline at end of file