Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix executable_path type error by utilising service when connecting to selenium #135

Open
wants to merge 2 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 9 additions & 9 deletions scrapy_selenium/middlewares.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,24 +46,24 @@ def __init__(self, driver_name, driver_executable_path,
for argument in driver_arguments:
driver_options.add_argument(argument)

driver_kwargs = {
'executable_path': driver_executable_path,
f'{driver_name}_options': driver_options
}

# locally installed driver
if driver_executable_path is not None:
driver_kwargs = {
service_module = import_module(f'{webdriver_base_path}.service')
service_klass = getattr(service_module, 'Service')
service_kwargs = {
'executable_path': driver_executable_path,
f'{driver_name}_options': driver_options
}
service = service_klass(**service_kwargs)
driver_kwargs = {
'service': service,
'options': driver_options
}
self.driver = driver_klass(**driver_kwargs)
# remote driver
elif command_executor is not None:
from selenium import webdriver
capabilities = driver_options.to_capabilities()
self.driver = webdriver.Remote(command_executor=command_executor,
desired_capabilities=capabilities)
options=driver_options)

@classmethod
def from_crawler(cls, crawler):
Expand Down
2 changes: 1 addition & 1 deletion setup.cfg
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[metadata]
name = scrapy-selenium
version = 0.0.7
version = 0.0.8
url = https://github.com/clemfromspace/scrapy-selenium
licence = DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
description = Scrapy with selenium
Expand Down
25 changes: 9 additions & 16 deletions setup.py
Original file line number Diff line number Diff line change
@@ -1,15 +1,8 @@
"""This module contains the packaging routine for the pybook package"""

from setuptools import setup, find_packages
try:
from pip.download import PipSession
from pip.req import parse_requirements
except ImportError:
# It is quick hack to support pip 10 that has changed its internal
# structure of the modules.
from pip._internal.download import PipSession
from pip._internal.req.req_file import parse_requirements

import pathlib
import pkg_resources

def get_requirements(source):
"""Get the requirements from the given ``source``
Expand All @@ -18,17 +11,17 @@ def get_requirements(source):
----------
source: str
The filename containing the requirements

"""
with pathlib.Path(source).open() as requirements_txt:
install_req = [
str(requirement)
for requirement
in pkg_resources.parse_requirements(requirements_txt)
]

install_reqs = parse_requirements(filename=source, session=PipSession())

return [str(ir.req) for ir in install_reqs]

return install_req

setup(
packages=find_packages(),
install_requires=get_requirements('requirements/requirements.txt')
)