我有一个使用splinter的python webscraping脚本,我想能够在远程机器上触发。我想知道是否有办法实现这一点,而无需设置Java Selenium Server。我已经验证了脚本在本地触发时在主机上运行没有问题。
from splinter import Browser
import time
browser = Browser('firefox', profile=r'C:\Users\user\AppData\Roaming\Mozilla\Firefox\Profiles\0r9gezm5.default')
browser.visit('https://confluence.com')
browser.find_by_id('login-link').click()
browser.fill('os_username', 'user')
browser.fill('os_password', 'pass')
browser.find_by_name('login').click()
with open ("C:\Webscraping\Download List\Contacts.txt") as sheet:
for website in sheet:
browser.visit(website)
browser.find_by_id('action-menu-link').click()
browser.find_by_id('action-export-pdf-link').click()
当尝试通过命令行远程触发脚本时,我收到以下错误:
Traceback (most recent call last):
File "\\host\c$\Webscraping\Scripts\Contacts.py", line 6, in <module>
browser = Browser('firefox', profile=r'C:\Users\user\AppData\Roaming\Mozilla\Firefox\Profiles\0r9gezm5.default')
File "C:\Anaconda2\lib\site-packages\splinter\browser.py", line 63, in Browser
return driver(*args, **kwargs)
File "C:\Anaconda2\lib\site-packages\splinter\driver\webdriver\firefox.py", line 57, in __init__
timeout=timeout, **kwargs)
File "C:\Anaconda2\lib\site-packages\selenium\webdriver\firefox\webdriver.py",
line 158, in __init__
keep_alive=True)
File "C:\Anaconda2\lib\site-packages\selenium\webdriver\remote\webdriver.py",
line 154, in __init__
self.start_session(desired_capabilities, browser_profile)
File "C:\Anaconda2\lib\site-packages\selenium\webdriver\remote\webdriver.py",
line 243, in start_session
response = self.execute(Command.NEW_SESSION, parameters)
File "C:\Anaconda2\lib\site-packages\selenium\webdriver\remote\webdriver.py",
line 312, in execute
self.error_handler.check_response(response)
File "C:\Anaconda2\lib\site-packages\selenium\webdriver\remote\errorhandler.py
", line 237, in check_response
raise exception_class(message, screen, stacktrace)
selenium.common.exceptions.WebDriverException: Message: connection reset
cmd exited on ch0pwts01 with error code 1.