栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 面试经验 > 面试问答

Android的HtmlUnit替代品?

面试问答 更新时间: 发布时间: IT归档 最新发布 模块sitemap 名妆网 法律咨询 聚返吧 英语巴士网 伯小乐 网商动力

Android的HtmlUnit替代品?

伙计们,我找到了另一种方法。由于我知道服务器地址,因此我尝试使用将数据直接发布到该地址

DataOutputStream
。看下面的代码:

public String searchDirectory() throws IOException {    URL url = new URL("https://www.xxxxx.com/xxxxx/xxxxx.cgi");    URLConnection con = url.openConnection();    con.setDoInput(true);    con.setDoOutput(true);    con.setUseCaches(false);    con.setRequestProperty("Content-Type", "application/x-www-form-urlenpred");    DataOutputStream printout = new DataOutputStream (con.getOutputStream ());    String parameters =("name=" + URLEnprer.enpre("DATA HERE", "UTF-8"));    printout.writeBytes (parameters);    printout.flush ();    printout.close ();            DataInputStream input = new DataInputStream (con.getInputStream ());    String line;    String htmlCode = "";    while((line = input.readLine()) != null) {        htmlCode += line;    }    return htmlCode;}

如您所见,我使用Html
Elements的名称通过java访问它们。但是,正如您从原始文章中的html表单代码中看到的那样,单选按钮具有相同的名称,如何在不使用其名称的情况下分别访问/填充它们?



转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/417639.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号