private void initPane() { // WebEngine engine = optionView.getEngine(); try { Document document = Jsoup.connect(webView.getEngine().getLocation()).get(); Element table = document.select("#normal_basket_" + document.select("[name=item_id]").val()).first(); Element td = table.select("td").first(); Elements spans = td.select("span"); Elements selects = td.select("select"); // System.out.println(spans.size()); cmb = new ArrayList<ComboBox>(); for (int i = 0; i < spans.size(); i++) { ObservableList<ValuePair> obs = FXCollections.observableArrayList(); Elements options = selects.get(i).select("option"); for (int k = 0; k < options.size(); k++) { Element option = options.get(k); obs.add(new ValuePair("choice", option.text(), option.val())); } cmb.add(new ComboBox<ValuePair>(obs)); optionArea.getChildren().addAll(new Text(spans.get(i).text()), cmb.get(i)); } } catch (Exception e) { // TODO 自動生成された catch ブロック e.printStackTrace(); } }
@Override public void initialize(URL location, ResourceBundle resources) { urlField.setOnAction( event -> { String text = urlField.getText(); urlField.setText("tetetetetetetete"); webView.getEngine().load(text); }); webView .getEngine() .getLoadWorker() .stateProperty() .addListener( (ov, oldState, newState) -> { if (newState == State.SUCCEEDED) { String url = webView.getEngine().getLocation(); urlField.setText(url); if (Pattern.compile("http://item.rakuten.co.jp/.*").matcher(url).find()) { try { Elements tmp; Document document = Jsoup.connect(url).get(); tmp = document.select("input"); tmp = tmp.select("#etime"); if (tmp.size() != 0) { if (!(Long.parseLong(tmp.first().val()) < new Date().getTime())) { entryButton.setDisable(false); } } else { entryButton.setDisable(false); } } catch (Exception e) { // TODO 自動生成された catch ブロック e.printStackTrace(); } } } ; }); entryButton.setOnAction( event -> { urlField.setText("webView disable"); sendEntryTaskController(); }); }
@Override public void initialize(URL location, ResourceBundle resources) { // TODO 自動生成されたメソッド・スタブ addOption.setOnAction( event -> { for (int i = 0; i < cmb.size(); i++) { // System.out.println(cmb.get(i).getValue()); if (cmb.get(i).getValue() == null) { break; } else if (i == cmb.size() - 1) { addTask.setDisable(false); } } }); addTask.setOnAction( event -> { try { String url = webView.getEngine().getLocation(); System.out.println(url); Document document = Jsoup.connect(url).get(); Elements input = document.select("input"); Map params = new HashMap<String, String>(); for (ComboBox cmbx : cmb) { ValuePair vp = (ValuePair) cmbx.getValue(); params.put(vp.getName(), vp.getvalue()); } // System.out.println(input.select("[name=shop_bid]").first()); // System.out.println(input.select("[name=shop_bid]").first().val()); params.put("shop_bid", input.select("[name=shop_bid]").first().val()); params.put("item_id", input.select("[name=item_id]").first().val()); params.put("__event", input.select("[name=__event]").first().val()); params.put("units", "1"); Map map = new HashMap<String, Long>(); // System.out.println(document.select("#stime").size()); if (document.select("#stime").size() != 0) { System.out.println(document.select("#stime")); map.put("stime", Long.parseLong((input.select("#stime").first().val()))); map.put("etime", Long.parseLong((input.select("#etime").first().val()))); } else { map = null; } BuyTask task = new BuyTask(url, params, map); task.call(); this.getScene().getWindow().hide(); } catch (Exception e) { // TODO 自動生成された catch ブロック e.printStackTrace(); } }); }