资源简介
用java程序实现换头像,自己钻研了好长时间,实在不容易,
代码片段和文件信息
package test;
import java.io.File;
import java.io.IOException;
import java.net.MalformedURLException;
import java.net.URL;
import java.util.ArrayList;
import java.util.List;
import junit.framework.TestCase;
import script._topic._381;
import verify.PictureZoom;
import base.SiteUser;
import base.WY_ERROR;
import base.WebUnit;
import base.WyException;
import com.gargoylesoftware.htmlunit.FormEncodingType;
import com.gargoylesoftware.htmlunit.HttpMethod;
import com.gargoylesoftware.htmlunit.Page;
import com.gargoylesoftware.htmlunit.WebClient;
import com.gargoylesoftware.htmlunit.WebRequest;
import com.gargoylesoftware.htmlunit.util.KeyDataPair;
import com.gargoylesoftware.htmlunit.util.NameValuePair;
public class test_changeHead_381 extends TestCase {
public void test_head() {
SiteUser user = new SiteUser();
user.setId(60270000);
user.setUserName(“viveinnes“);
user.setPassWord(“inti712“);
_381 script = new _381();
try {
script.login(user);
} catch (WyException e) {
e.printStackTrace();
}
if (script.IsLogin() == WY_ERROR.RESULT_OK) {
System.out.println(“登陆成功“);
}
WebClient client = script.getClient();
Page page = script.getPage();
String url = “https://ssl.k12.com.cn/platform/index.php?t=profile_avatar“;
try {
WebUnit.wait(2);
page = client.getPage(url);
} catch (IOException e) {
e.printStackTrace();
}
WebRequest req=null;
try {
req=new WebRequest(new URL(“https://ssl.k12.com.cn/platform/index.php“) HttpMethod.POST);
} catch (MalformedURLException e) {
e.printStackTrace();
}
req.setEncodingType(FormEncodingType.MULTIPART);
req.setAdditionalHeader(“Accept“ “text/html application/xhtml+xml */*“);
ArrayList
- 上一篇:hello service
- 下一篇:树形菜单显示集锦jsp版
评论
共有 条评论