Skip to content

Commit 2c414ac

Browse files
committed
Fail gracefully on SPLASH_URL without protocol
1 parent e40ca4f commit 2c414ac

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

scrapy_splash/middleware.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
import copy
55
import json
66
import logging
7+
import re
78
import warnings
89
from collections import defaultdict
910

@@ -233,6 +234,11 @@ def __init__(self, crawler, splash_base_url, slot_policy, log_400):
233234
def from_crawler(cls, crawler):
234235
splash_base_url = crawler.settings.get('SPLASH_URL',
235236
cls.default_splash_url)
237+
if not re.match('^https?://', splash_base_url):
238+
raise NotConfigured(
239+
'The SPLASH_URL setting does not start with http:// or '
240+
'https://: {}'.format(splash_base_url)
241+
)
236242
log_400 = crawler.settings.getbool('SPLASH_LOG_400', True)
237243
slot_policy = crawler.settings.get('SPLASH_SLOT_POLICY',
238244
cls.default_policy)

0 commit comments

Comments
 (0)