爪哇
我有这样一种情况,我必须以表单提交的结果获取响应的Web内容,但是有点麻烦,因为流程不像请求和响应那样简单,如下所示。

Submit button pressed -> Display page processing wait timer -> Display quick advertisement page -> Display page result.


从“按下提交按钮”开始,我想拥有“显示页面结果”的内容,并在其间跳过页面。

我有此示例代码,但它仅以一种方式工作,即发送请求和接收响应。

URL url;
InputStream is = null;
DataInputStream dis;
String line;

try {
    url = new URL("http://stackoverflow.com/");
    is = url.openStream();  // throws an IOException
    dis = new DataInputStream(new BufferedInputStream(is));

    while ((line = dis.readLine()) != null) {
        System.out.println(line);
    }
} catch (MalformedURLException mue) {
     mue.printStackTrace();
} catch (IOException ioe) {
     ioe.printStackTrace();
} finally {
    try {
        is.close();
    } catch (IOException ioe) {
        // nothing to see here
    }
}


任何Java库都可以为我做?提前致谢。

最佳答案

考虑尝试Selenium web driver。也许它具有您要实现的功能。

10-06 14:39
查看更多