Skip to content

Commit

Permalink
[UPDATE] add the option to run selenium in headless mode
Browse files Browse the repository at this point in the history
  • Loading branch information
mehdiirh committed May 6, 2024
1 parent 9f2dd53 commit 633b9a2
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 21 deletions.
7 changes: 7 additions & 0 deletions core/selenium.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
from time import sleep

from django.conf import settings
from selenium import webdriver
from selenium.webdriver.common.by import By

Expand All @@ -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
Expand All @@ -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: "
)
Expand Down
42 changes: 22 additions & 20 deletions relohub/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -123,13 +123,35 @@ 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")
TIME_ZONE = env_default("TIME_ZONE", "UTC")
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"
Expand All @@ -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",
]
4 changes: 3 additions & 1 deletion sample.env
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,6 @@ REDIS_BIND_PORT=
LANGUAGE_CODE=en-US
TIME_ZONE=Asia/Tehran

CELERY_BROKER_URL=redis://
CELERY_BROKER_URL=redis://

SELENIUM_HEADLESS=True

0 comments on commit 633b9a2

Please sign in to comment.