예제 #1
0
  @Override
  public void crawlFillWriteConfigurations() throws InterruptedException, IOException, Exception {
    this.openFirefox();
    this.loadWebpage();
    Thread.sleep(3000);

    List<WebElement> boxs = driver.findElements(By.className("pricing-box"));
    // System.out.println("boxs Size : "+boxs.size());
    for (WebElement box : boxs) {
      Configuration config = new Configuration();
      config.setProvider(this);

      box.click(); // otherwise, elements don't load
      List<WebElement> lis = box.findElements(By.tagName("li"));
      // System.out.println("lis Size : "+lis.size());
      // System.out.println("------------------------");
      for (WebElement li : lis) {
        // System.out.println("li text : "+li.getText());
        if (li.getText().contains("Core")) {
          double cpu = this.extractNumber(li.getText());
          config.setCpu(cpu);
        } else if (li.getText().contains("month")) {
          double price = this.extractNumber(li.getText());
          config.setPrice(price);
        } else if (li.getText().contains("RAM")) {
          double ram = this.extractNumber(li.getText());
          config.setRam(ram);
        } else if (li.getText().contains("Storage")) {
          double disk = this.extractNumber(li.getText());
          config.setSsd(disk);
        }
      }
      config.setDate(this.getDate());
      this.configurations.add(config);
    }

    this.closeFirefox();
    if (!SipsRdf.verbose) {
      System.out.println("");
    }
    this.writeConfigurationsInCsv();
  }
예제 #2
0
  @Override
  public void crawlFillWriteConfigurations() throws InterruptedException, IOException, Exception {
    this.openFirefox();
    this.loadWebpage();
    Thread.sleep(3000);

    for (int transferActual = 0;
        transferActual < this.transferClick;
        transferActual += (this.transferClick * this.crawlSpeed)) {
      for (int diskActual = 0;
          diskActual < this.diskClick;
          diskActual += (this.diskClick * this.crawlSpeed)) {
        for (int ramActual = 0;
            ramActual < this.ramClick;
            ramActual += (this.ramClick * this.crawlSpeed)) {
          for (int cpuActual = 0;
              cpuActual < this.cpuClick;
              cpuActual += (this.cpuClick * this.crawlSpeed)) {
            Configuration config = new Configuration(); // For linux config
            config.setProvider(this);
            config.setCpu(this.getCpu());
            config.setRam(this.getRam());
            config.setHdd(this.getDisk());
            config.setTransferSpeed(this.getTransfer());
            config.setPrice(this.getPrice());
            config.setOsUri(URI.linux);
            config.setDate(this.getDate());
            this.configurations.add(config);
            config.println();

            Configuration config2 = new Configuration(); // For windows config
            config2.setProvider(this);
            config2.setCpu(this.getCpu());
            config2.setRam(this.getRam());
            config2.setHdd(this.getDisk());
            config2.setTransferSpeed(this.getTransfer());
            config2.setPrice(this.getPrice() + this.getWindowsPrice());
            config2.setOsUri(URI.windows);
            config2.setDate(this.getDate());
            this.configurations.add(config2);
            config2.println();

            this.mooveCpu((this.cpuClick * this.crawlSpeed));
          }
          this.mooveCpu(-this.cpuClick);
          this.mooveRam((this.ramClick * this.crawlSpeed));
        }
        this.mooveRam(-this.ramClick);
        this.mooveDisk((this.diskClick * this.crawlSpeed));
      }
      this.mooveDisk(-this.diskClick);
      this.mooveTransfer((this.transferClick * this.crawlSpeed));
    }

    Thread.sleep(3000);
    this.closeFirefox();
    if (!SipsRdf.verbose) {
      System.out.println("");
    }
    this.writeConfigurationsInCsv();
  }
예제 #3
0
  public void addConfigurationExoScale(
      String configName, int cpuValue, double ramValue, boolean windows) throws Exception {
    Configuration config = new Configuration();
    config.setProvider(this);
    config.setConfigName(configName);
    config.setCpu(cpuValue);
    config.setRam(ramValue);

    WebElement disk =
        driver
            .findElement(By.className("summary"))
            .findElement(By.className("hdd"))
            .findElement(By.className("spec-value"));
    double diskValue = this.extractNumber(disk.getText());
    // System.out.println("disk : "+diskValue);

    config.setSsd(diskValue);
    if (windows) {
      config.setOsUri(URI.windows);
    } else {
      config.setOsUri(URI.linux);
    }

    Thread.sleep(500);
    WebElement price =
        driver
            .findElement(By.className("summary"))
            .findElement(By.className("price-month"))
            .findElement(By.className("price-value"));
    double priceValue = Double.parseDouble(price.getText());
    // System.out.println("price : "+priceValue);
    config.setPrice(priceValue);

    config.setDate(this.getDate());
    config.println();
    this.configurations.add(config);
  }