Skip to content
This repository was archived by the owner on Apr 29, 2025. It is now read-only.

Commit feae95f

Browse files
committed
Update Web Crawling Pipeline
1 parent ce53d08 commit feae95f

File tree

5 files changed

+9
-7
lines changed

5 files changed

+9
-7
lines changed

.env.example

+1
Original file line numberDiff line numberDiff line change
@@ -16,3 +16,4 @@ EMAIL_HOST_PASSWORD=
1616
EMAIL_PORT=1025
1717
EMAIL_USE_TLS=False
1818
DOMAIN=localhost
19+
SELENIUM_HEADLESS=False

.env.testing

+1
Original file line numberDiff line numberDiff line change
@@ -16,3 +16,4 @@ EMAIL_HOST_PASSWORD=
1616
EMAIL_PORT=1025
1717
EMAIL_USE_TLS=False
1818
DOMAIN=localhost
19+
SELENIUM_HEADLESS=True

.github/workflows/build.yml

+2-6
Original file line numberDiff line numberDiff line change
@@ -47,10 +47,7 @@ jobs:
4747
- uses: nanasess/setup-chromedriver@v2
4848
with:
4949
chromedriver-version: '88.0.4324.96'
50-
- run: |
51-
export DISPLAY=:99
52-
chromedriver --url-base=/wd/hub &
53-
sudo Xvfb -ac :99 -screen 0 1280x1024x24 > /dev/null 2>&1 &
50+
- run: chromedriver --url-base=/wd/hub &
5451

5552
- name: Create environment file
5653
run: cp .env.testing .env
@@ -59,8 +56,7 @@ jobs:
5956
python -m pip install --upgrade pip
6057
pip install -r requirements.txt
6158
- name: See your Python code do web browsing on your screen with GUI
62-
run: |
63-
python manage.py crawl
59+
run: python manage.py crawl
6460
- name: Upload Screenshots
6561
uses: actions/upload-artifact@v3
6662
with:

app/settings.py

+2
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@
1818
DEBUG=(bool,False)
1919
)
2020

21+
SELENIUM_HEADLESS=env('SELENIUM_HEADLESS', False)
22+
2123
# Build paths inside the project like this: BASE_DIR / 'subdir'.
2224
BASE_DIR = Path(__file__).resolve().parent.parent
2325

seleniumpy/management/commands/crawl.py

+3-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
from django.core.management.base import BaseCommand, CommandError
2+
from django.conf import settings
23

34
import os
45
import json
@@ -21,7 +22,8 @@ def handle(self, *args, **options):
2122
userAgent = 'Mozilla/5.0 (BB10; Touch) AppleWebKit/537.1+ (KHTML, like Gecko) Version/10.0.0.1337 Mobile Safari/537.1+'
2223
chrome_options.add_argument('--user-agent='+userAgent)
2324
# Uncomment next line to remove GUI.
24-
# chrome_options.add_argument('--headless')
25+
if settings.SELENIUM_HEADLESS == True:
26+
chrome_options.add_argument('--headless')
2527
browser = webdriver.Chrome(options=chrome_options)
2628

2729
browser.get('https://www.kelvinkamara.com')

0 commit comments

Comments
 (0)