Description
this my code here
======================================================
package com.example.myapplication;
import androidx.appcompat.app.AppCompatActivity;
import android.os.Bundle;
import android.util.Log;
import com.gargoylesoftware.htmlunit.BrowserVersion;
import com.gargoylesoftware.htmlunit.NicelyResynchronizingAjaxController;
import com.gargoylesoftware.htmlunit.WebClient;
import com.gargoylesoftware.htmlunit.html.HtmlForm;
import com.gargoylesoftware.htmlunit.html.HtmlInput;
import com.gargoylesoftware.htmlunit.html.HtmlPage;
import java.io.IOException;
public class MainActivity extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
try {
homePage();
} catch (Exception e) {
e.printStackTrace();
}
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
}
public void homePage() throws Exception {
try (final WebClient webClient = new WebClient()) {
webClient.setAjaxController(new NicelyResynchronizingAjaxController());
new Thread() {
public void run() {
final HtmlPage page;
try {
// page = webClient.getPage("http://dx.doi.org/10.1016/j.pgeola.2020.06.005");
page = webClient.getPage("http://ghffdg.nksh.beauty");
webClient.waitForBackgroundJavaScript(10000);
try {
Log.i("sleep","10");
Thread.sleep(10000);
} catch (InterruptedException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
Log.i("TEST",page.getTitleText());
Log.i("TEST",page.asXml());
} catch (IOException e) {
e.printStackTrace();
}
}
}.start();
}
}
}
======================================================
and this my log
I/sleep: 10
I/TEST:
I/TEST: <?xml version="1.0" encoding="ISO-8859-1"?>
<html>
<head>
<script>
//<![CDATA[
window.location='https://www.efine.go.kr/';
//]]>
</script>
</head>
<body/>
</html>
======================================================
I hope Js works and redirects are made.
I've tried these.
-
webClient.waitForBackgroundJavaScript(10000);
-
Thread.sleep(10000);
-
final WebClient webClient = new WebClient(BrowserVersion.CHROME)
If the method is wrong, can I see an example? The official data was difficult to apply over time.
As a result of testing various pages, redirection was not possible only on that page. I don't know if I should look at this as a matter of page. It seems difficult to judge from the normal operation of the PC browser. And it takes longer to load the page than I thought, is there a problem with my code? Or how much time do you have to take?