私のアカウント内の自動更新ページコンテンツ用のアプリケーションを作成しようとしています。私はそれがjavascriptをサポートしているので、HTMLUnitを使用しました。 しかし、私は "あなたのブラウザが古すぎます"という問題に直面しました。HTMLUnit Java too old browser
マイコード:
public static void main(String[] args) {
Locale.setDefault(Locale.ENGLISH);
try (final WebClient client = new WebClient(BrowserVersion.FIREFOX_45)) {
client.getOptions().setUseInsecureSSL(true);
client.setAjaxController(new NicelyResynchronizingAjaxController());
client.getOptions().setThrowExceptionOnFailingStatusCode(false);
client.getOptions().setThrowExceptionOnScriptError(false);
client.waitForBackgroundJavaScript(30000);
client.waitForBackgroundJavaScriptStartingBefore(30000);
client.getOptions().setCssEnabled(false);
client.getOptions().setJavaScriptEnabled(true);
client.getOptions().setRedirectEnabled(true);
HtmlPage page = client.getPage("https://passport.yandex.ru/passport?mode=auth&retpath=https://toloka.yandex.ru/?ncrnd=5645");
HtmlForm form = page.getForms().get(0);
HtmlInput inputLogin = form.getInputByName("login");
inputLogin.setValueAttribute(userName);
HtmlInput inputPassw = form.getInputByName("passwd");
inputPassw.setValueAttribute(password);
DomElement button = page.getElementsByTagName("button").get(0);
HtmlPage page2 = button.click();
System.out.println(page2.asXml());
}
catch (IOException e) {
}
}
ログインが成功しているが、私は2番目のページをロードすることはできません。
<h1 style="padding-top: 20px;">Browser is too old</h1>
<p>
Unfortunately you are using an old browser.
Please, upgrade to at least IE10 or use one of the modern browsers, e.g.
<a href="http://browser.yandex.net/">Yandex.Browser</a>,
<a href="https://www.google.com/chrome/browser/">Google Chrome</a> or
<a href="https://www.mozilla.org/firefox/new/">Mozilla Firefox</a>
</p>
どのように私はそれを解決することができます。
回答を(これは、コンテンツページにリダイレクトする必要がありますか)?ありがとう。
ありがとうございますが、役に立たないです。 Jan 22、2017 8:57:38 PM com.gargoylesoftware.htmlunit.IncorrectnessListenerImpl通知 警告:廃止されたコンテンツタイプが見つかりました: 'application/x-javascript'。 (私はそれが私がJSを全く知らないので何を意味するのか分かりません) – Limmy
だから、Javaでこのアプリを行う方法はありませんか? – Limmy
「ありがとうございますが、助けにならない」 - 何が助けになりませんか?ログ出力について:これは警告ですが、これは無視できます。また、Webページを自動化したい場合は、Http、Html、JavascriptなどのWebの基礎知識が必要です。 – RBRi