public static void main(String[] args) {
CloseableHttpClient httpclient = HttpClientBuilder.create().build();
HttpPost hp = new HttpPost("http://192.168.1.1");
StringEntity entity2;
try {
entity2 = new StringEntity("{\"method\":\"do\",\"login\":{\"password\":\"vxcTrV4u9TefbwK\"}}");
hp.setEntity(entity2);
CloseableHttpResponse response = httpclient.execute(hp);
//System.out.println(EntityUtils.toString(response.getEntity(), "utf-8"));
Matcher m = Pattern.compile("\"stok\":\"(.+?)\"").matcher(EntityUtils.toString(response.getEntity(), "utf-8"));
if(m.find()){
HttpPost hp2 = new HttpPost("http://192.168.1.1/stok="+m.group(1)+"/ds");
entity2 = new StringEntity("{\"network\":{\"change_wan_status\":{\"proto\":\"pppoe\",\"operate
JAVA 实现 TP-LINK路由器拨号
最新推荐文章于 2021-03-21 19:12:30 发布
这篇博客展示了如何用JAVA编程实现对TP-LINK路由器的拨号操作。通过创建HttpClient发送POST请求,设置登录凭证并匹配响应中的stok值,然后进行断开和连接拨号操作。代码中详细说明了每个步骤,包括HTTP请求的构造和响应的处理。
摘要由CSDN通过智能技术生成