如何使用DigitalOcean浮动IP

时间:2018-06-13 04:59:26

标签: python selenium digital-ocean

使用DigitalOcean上的Droplet,在Python中启动Selenium WebDriver时是否可以使用浮动ip?

这是用于启动webdriver的代码。我需要做些什么才能使用浮动IP?

from selenium import webdriver
browser = webdriver.Chrome(my_driver_location, chrome_options=chromeOptions)
browser.get(start_page)

1 个答案:

答案 0 :(得分:0)

替换

function submitBtn(){
  // Get the modal
  var modals = document.getElementsByClassName('modal');
  // Get the button that opens the modal
  var btns = document.getElementsByClassName("pop-up");
  var spans=document.getElementsByClassName("close-modal");

  for(let i=0;i<btns.length;i++){
    btns[i].onclick = function(){
      modals[i].style.display = "block";
    }
  }

  for(let i=0;i<spans.length;i++){
    spans[i].onclick = function(){
      modals[i].style.display = "none";
    }
  }

  // When the user clicks anywhere outside of the modal, close it
  window.addEventListener('click', function(){
    var modals = document.getElementsByClassName('modal');

  for(let i = 0; i < modals.length; i++){
    modals[i].style.display = "none";
  }
  });
}

具有:

.modal {
  display: none; /* Hidden by default */
  position: fixed; /* Stay in place */
  z-index: 10; /* Sit on top */
  padding-top: 100px; /* Location of the box */
  left: 0;
  top: 0;
  width: 100%; /* Full width */
  height: 100%; /* Full height */
  overflow: auto; /* Enable scroll if needed */
  background-color: rgb(0,0,0); /* Fallback color */
  background-color: rgba(0,0,0,0.4); /* Black w/ opacity */
}

.modal-content {
  background-color: #fefefe;
  margin: auto;
  padding: 20px;
  border: 1px solid #888;
  width: 80%;
  display: table;
}

/* Modal Content */
.modal-content div {
  padding: 5px;
  margin: 5px;
}

/* The Close Button */
.close-modal {
  color: #aaaaaa;
  text-align: right;
  font-size: 28px;
  font-weight: bold;
}

.close-modal:hover,
.close-modal:focus {
  color: #000;
  text-decoration: none;
  cursor: pointer;
}

192.168.99.100是您的浮动IP, 4444是您的浮动IP的端口