欧美一区二区三区老妇人-欧美做爰猛烈大尺度电-99久久夜色精品国产亚洲a-亚洲福利视频一区二区

java偽代碼登錄 java命令模式偽代碼

java 模擬post登錄

這個要分兩步,先用GET方法取得頁面源碼,分析出mpc的值,然后用POST方法發(fā)送數(shù)據(jù)就能登錄了。當(dāng)然一切工作之前要設(shè)置好CookieHandler

成都創(chuàng)新互聯(lián)公司專注于金昌企業(yè)網(wǎng)站建設(shè),自適應(yīng)網(wǎng)站建設(shè),商城網(wǎng)站開發(fā)。金昌網(wǎng)站建設(shè)公司,為金昌等地區(qū)提供建站服務(wù)。全流程定制網(wǎng)站開發(fā),專業(yè)設(shè)計,全程項目跟蹤,成都創(chuàng)新互聯(lián)公司專業(yè)和態(tài)度為您提供的服務(wù)

post頁面:

;pageref=

post參數(shù)就4個啟旅悔而已,

name=yourNamepwd=yourPasswordB12=Loginmpc=分析得到的mpc

看鎮(zhèn)余如下例子:

將這個例子中的如下語句改一下就能收到數(shù)據(jù)的

connection.getInputStream().close();

//

import java.io.BufferedInputStream;

import java.io.DataOutputStream;

import java.io.InputStream;

import java點虐 .CookieHandler;

import java點虐 .CookieManager;

import java點虐 .CookiePolicy;

import java點虐 .HttpURLConnection;

import java點虐 .URL;

import java.util.regex.Matcher;

import java.util.regex.Pattern;

public class SongTaste {

private static String baseURL="";

private static String loginURL=baseURL+"/signin.php";

private static String actionURL=baseURL+"悄正/info_oper.php?tag=signinpageref=";

private static String musicURL=baseURL+"/music/";

private static CookieManager cm;

static{

cm=new CookieManager();

cm.setCookiePolicy(CookiePolicy.ACCEPT_ALL);

CookieHandler.setDefault(cm);

}

public static void main(String[] args) throws Exception{

// HttpURLConnection.setFollowRedirects(true);

login("abcmusic","000000");

listContents();

}

private static void listContents() throws Exception {

byte[] dat=new HttpGet(musicURL).data;

String src=new String(dat,"gbk");

Matcher m=Pattern點抗 pile("MSL\\(.*?\\)").matcher(src);

while(m.find())

System.out.println(m.group());

}

private static void login(String name,String pwd){

byte[] dat=new HttpGet(loginURL).data;

String src=new String(dat);

Matcher m=Pattern點抗 pile("name=mpc.*?").matcher(src);

String mpc="";

if(m.find()){

mpc=m.group();

// System.out.println(mpc);

mpc=mpc.substring(15,mpc.length()-1);

// System.out.println(mpc);

}

//do login

new HttpPost(actionURL,String.format("name=%spwd=%sB12=Loginmpc=%s",name,pwd,mpc));

}

private static class HttpGet extends Thread{

private static final int bufferSize=1024;

private String ustr;

private byte[] data;

private HttpGet(String u,String...ref){

ustr=u;

start();

try {join();} catch (Exception e) {}

}

public void run(){

try{

URL u = new URL(ustr);

HttpURLConnection uc=(HttpURLConnection)u.openConnection();

byte[] b={};

byte[] t=new byte[bufferSize];

int r;

BufferedInputStream bin=new BufferedInputStream(uc.getInputStream());

while((r=bin.read(t))-1){

b=putData(b,t,r);

}

bin.close();

uc.disconnect();

data=b;

}catch(Exception e){}

}

private final byte[] putData(byte[] b, byte[] t, int r) {

byte[] tb=new byte[b.length+r];

System.arraycopy(b, 0, tb, 0, b.length);

System.arraycopy(t, 0, tb, b.length, r);

return tb;

}

}

private static class HttpPost extends Thread{

private static int blen=1024;

private static String contentType="application/x-www-form-urlencoded";

private String url,pms;

private byte[] dat={};

private HttpPost(String u,String p){

url=u;

pms=p;

start();

try{join();}catch(Exception e){}

}

public void run(){

try{

URL u = new URL(url);

HttpURLConnection connection=(HttpURLConnection)u.openConnection();

connection.setRequestMethod("POST");

connection.setRequestProperty("Content-Type",contentType);

connection.setRequestProperty("Content-Length",String.valueOf(pms.length()));

connection.setUseCaches(false);

connection.setDoOutput(true);

connection.setDoInput(true);

DataOutputStream dout=new DataOutputStream(connection.getOutputStream());

dout.write(pms.getBytes());

dout.flush();

dout.close();

InputStream in=connection.getInputStream();

BufferedInputStream bin=new BufferedInputStream(in);

byte[] buff=new byte[blen],bs={};

int r;

while((r=bin.read(buff))-1){

bs=putData(bs,buff,r);

}

bin.close();

connection.disconnect();

dat=bs;

}catch(Exception e){}

}

private final byte[] putData(byte[] b, byte[] t, int r) {

byte[] tb=new byte[b.length+r];

System.arraycopy(b, 0, tb, 0, b.length);

System.arraycopy(t, 0, tb, b.length, r);

return tb;

}

}

}

網(wǎng)頁名稱:java偽代碼登錄 java命令模式偽代碼
文章鏈接:http://chinadenli.net/article30/dshosso.html

成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供企業(yè)建站網(wǎng)站內(nèi)鏈品牌網(wǎng)站設(shè)計GoogleApp開發(fā)

廣告

聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請盡快告知,我們將會在第一時間刪除。文章觀點不代表本網(wǎng)站立場,如需處理請聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時需注明來源: 創(chuàng)新互聯(lián)

h5響應(yīng)式網(wǎng)站建設(shè)