伙计们,我找到了另一种方法。由于我知道服务器地址,因此我尝试使用将数据直接发布到该地址
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表单代码中看到的那样,单选按钮具有相同的名称,如何在不使用其名称的情况下分别访问/填充它们?



