【问题标题】:How to programmatically send a POST request and parse the HTML result?如何以编程方式发送 POST 请求并解析 HTML 结果?
【发布时间】:2011-11-21 22:28:30
【问题描述】:

我用 Java 开发了一个应用程序。

  • 具有表student 和列useridpasswordnameaddress 的数据库。
  • login.html 页面要求 usernamepassword 并具有提交按钮。有一个<form action="display.jsp" method="post">
  • display.jsp 我正在打印姓名和地址。

这在浏览器中运行良好。

但现在我想制作一个简单的 Java 应用程序,我将在其中传递在 localhost 上运行的 login.html 的 URL。该Java应用程序应填写表格,单击该按钮并在控制台上打印名称和地址的值。当我从 1 到 20 使用 while 循环时,它将打印所有 20 名学生的姓名和地址。

我怎样才能做到这一点?

【问题讨论】:

    标签: java jsp servlets html-parsing


    【解决方案1】:

    这似乎是一种不可取的方式来实现这一点,但如果你必须这样做,你可以使用像 Apache Http Client 这样的东西...... http://hc.apache.org/httpcomponents-client-ga/index.html

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2013-07-17
      • 1970-01-01
      • 2012-04-02
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2018-12-20
      相关资源
      最近更新 更多