I want to get the HTML code of the following Web Page (http://www.studenti.ict.uniba.it/esse3/ListaAppelliOfferta.do) after:

我想在以下网址获取以下网页的HTML代码(http://www.studenti.ict.uniba.it/es​​se3/ListaAppelliOfferta.do):

  1. selecting "Dipartimento di Informatica" among Facoltà
  2. 在Facoltà中选择“Dipartimento di Informatica”

  3. selecting "Informatica" (or one of the others available)
  4. 选择“Informatica”(或其他可用的)

  5. clicking "Avvia Ricerca"
  6. 点击“Avvia Ricerca”

I am not very keen in the matter but I noticed the URL of the page stays the same after each selection!?!

我对此事并不是很热衷,但我注意到每次选择后页面的网址都保持不变!?!

Can anyone help describing, possibly in details, how can I do that? Unfortunately I am not expert in web programming.

任何人都可以帮助描述,可能在细节上,我该怎么做?不幸的是,我不是网络编程专家。

Many thanks

1 个解决方案

#1


1

After some tests, it refresh the pages with a POST request

经过一些测试后,它会使用POST请求刷新页面

fac_id:1012 --
cds_id:197  -- 
ad_id: -- Attività didattica
docente_id:  -- Id of the docent selected
data:06/03/2014 -- Date

Anyway you missed the value of Attività ditattica, Docente and Data esame

无论如何,你错过了Attivitàditattica,Docente和Data esame的价值

Just run a HTTP request using HttpURLConnection (?) with this POST args, and with a XML parser read the output of tplmessage table.

只需使用带有此POST参数的HttpURLConnection(?)运行HTTP请求,并使用XML解析器读取tplmessage表的输出。

Try this tutorial for HTTP request: click.

尝试本教程获取HTTP请求:单击。

Try to read this to understand how to parse response: click

尝试阅读本文以了解如何解析响应:单击


An example using the code of the tutorial:

使用本教程代码的示例:

HttpURLConnection connection = null;
try
{
    URL url = new URL("http://www.studenti.ict.uniba.it/esse3/ListaAppelliOfferta.do");
    connection = (HttpURLConnection) url.openConnection(); // open the connection with the url

    String params =
            "fac_id=1012&cds_id=197"; // You need to add ad_id, docente_id and data

    connection.setRequestMethod("POST"); // i need to use POST request method
    connection.setRequestProperty("Content-Length", "" + Integer.toString(params.getBytes().length)); // It will add the length of params

    connection.setRequestProperty("Content-Language", "it-IT"); // language italian

    connection.setUseCaches (false);
    connection.setDoInput   (true);
    connection.setDoOutput  (true);

    DataOutputStream wr = new DataOutputStream(
            connection.getOutputStream ());
    wr.writeBytes (params); // pass params
    wr.flush (); // send request
    wr.close ();

    //Get Response
    InputStream is = connection.getInputStream();
    BufferedReader rd = new BufferedReader(new InputStreamReader(is));
    String line;
    StringBuilder response = new StringBuilder();
    while((line = rd.readLine()) != null) {
        response.append(line);
        response.append('\r');
    }
    rd.close();
}
catch (MalformedURLException e)
{
    e.printStackTrace();
} catch (IOException e)
{
    e.printStackTrace();
}
finally
{
    // close connection if created
    if (connection != null)
        connection.disconnect();
}

In response you will have the DOM of the page.

作为回应,您将拥有该页面的DOM。


Anyway, use Chrome developers tool to get request args:

无论如何,使用Chrome开发人员工具来获取请求args:

更多相关文章

  1. TextView在单击时发送电子邮件
  2. Android 外部唤起应用跳转指定页面
  3. fragment保存页面不销毁
  4. Android欢迎页面自动跳转和触摸进入首页
  5. 通过ViewPager实现类似微信的页面切换(Fragment篇)
  6. android开发中如何从当前页面返回上一页面
  7. 在Webview上加载脱机更新页面
  8. 自定义BaseAdapter,在主Activity页面调用显示歌曲列表
  9. 提取Launcher中的WorkSapce,可以左右滑动切换屏幕页面的类

随机推荐

  1. Python安装第三方库太慢?配置好这个速度飞
  2. Jupyter Notebook最常用的五大配置技巧
  3. 对SVG动画进行异步懒光栅化处理 [每日前
  4. 基于geopandas的空间数据分析——空间计
  5. 怎样在服务器上启用 HTTPS [每日前端夜话
  6. matplotlib绘图的核心原理讲解
  7. matplotlib绘图技巧详解(一)
  8. 异步函数中的异常处理及测试方法 [每日前
  9. Python+Kepler.gl轻松制作酷炫路径动画
  10. Python笔下那些神奇的树