Skip to content

Commit e9ce7b9

Browse files
committed
Fixed compatibility with older scrapy releases
1 parent 9671684 commit e9ce7b9

File tree

2 files changed

+10
-3
lines changed

2 files changed

+10
-3
lines changed

scrapy_webdriver/download.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,14 @@
1-
from scrapy import log
1+
from scrapy import log, version_info
22
from scrapy.utils.decorator import inthread
33
from scrapy.utils.misc import load_object
44

55
from .http import WebdriverActionRequest, WebdriverRequest, WebdriverResponse
66

7-
FALLBACK_HANDLER = 'scrapy.core.downloader.handlers.http10.HTTP10DownloadHandler' # NOQA
7+
if map(int, version_info) < [0, 18]:
8+
FALLBACK_HANDLER = 'http.HttpDownloadHandler'
9+
else:
10+
FALLBACK_HANDLER = 'http10.HTTP10DownloadHandler'
11+
FALLBACK_HANDLER = 'scrapy.core.downloader.handlers.%s' % FALLBACK_HANDLER
812

913

1014
class WebdriverDownloadHandler(object):

scrapy_webdriver/selector.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
import re
22

3-
from scrapy.selector import Selector, XPathSelectorList
3+
try:
4+
from scrapy.selector import Selector, XPathSelectorList
5+
except ImportError: # scrapy < 0.20
6+
from scrapy.selector import XPathSelector as Selector, XPathSelectorList
47

58
_UNSUPPORTED_XPATH_ENDING = re.compile(r'.*/((@)?([^/()]+)(\(\))?)$')
69

0 commit comments

Comments
 (0)