Ошибка URL в Droplet

Следующий скрипт отлично работает на моем ноутбуке:

for elem,i in zip(range(10000), bar((range(10000)))):

    n = random.uniform(.01, 2)
    time.sleep(n)
    driver = webdriver.PhantomJS(desired_capabilities=desired_capabilities)
    driver.set_window_size(1120, 550)
    search_url = "https://www.parlament.ch/de/ratsbetrieb/amtliches-bulletin/amtliches-bulletin-die-videos?TranscriptId=" + str(elem)
    driver.get(search_url)

    try:
         element_present = EC.presence_of_element_located((By.XPATH, '//p[="ng-scope"]'))
         WebDriverWait(driver, 10).until(element_present)
    except:
         pass

    text = (driver.page_source).encode('utf-8')

    with open(time.strftime("parl_htmls/" + "%Y%m%d%H%M%S")+".htm", "wb+") as file:
        file.write(text)
        file.close()

driver.close()

Однако, когда я запускаю из Digital Ocean Droplet, я получаю следующие ошибки:

Traceback (most recent call last):
  File "script7_2.py", line 35, in <module>
  text = (driver.page_source).encode('utf-8')
  File "/usr/local/lib/python3.5/dist-
  packages/selenium/webdriver/remote/webdriver.py", line 573, in page_source
  return self.execute(Command.GET_PAGE_SOURCE)['value']
  File "/usr/local/lib/python3.5/dist-
  packages/selenium/webdriver/remote/webdriver.py", line 295, in execute
  response = self.command_executor.execute(driver_command, params)
  File "/usr/local/lib/python3.5/dist-packages/selenium/webdriver/remote/remote_connection.py", line 464, in execute
  return self._request(command_info[0], url, body=data)
   File "/usr/local/lib/python3.5/dist-packages/selenium/webdriver/remote/remote_connection.py", line 526, in _request
resp = opener.open(request, timeout=self._timeout)
  File "/usr/lib/python3.5/urllib/request.py", line 466, in open
response = self._open(req, data)
  File "/usr/lib/python3.5/urllib/request.py", line 484, in _open
'_open', req)
  File "/usr/lib/python3.5/urllib/request.py", line 444, in _call_chain
result = func(*args)
  File "/usr/lib/python3.5/urllib/request.py", line 1282, in http_open
return self.do_open(http.client.HTTPConnection, req)
  File "/usr/lib/python3.5/urllib/request.py", line 1256, in do_open
raise URLError(err)
urllib.error.URLError: <urlopen error [Errno 111] Connection refused>

У кого-нибудь есть идея, как решить эту проблему?

0 ответов

Другие вопросы по тегам