HttpGet发送用户名密码
android应用程序获取http网页数据,网页有密码用HttpGet 在url后面加password不管用
public void onClick(View v) {
new Thread(){
public void run(){
String uriApi="http://oem.card/publicdir/index.htm?password=0000";
HttpGet httpRequest = new HttpGet(uriApi);
try{
HttpResponse httpResponse = new DefaultHttpClient().execute(httpRequest);
if(httpResponse.getStatusLine().getStatusCode() == 200)
{
String strResult = EntityUtils.toString(httpResponse.getEntity());
System.out.println("get strResult="+strResult);
}
else
{
mTextView.setText("Error Response:"+httpResponse.getStatusLine().toString());
}
}catch(ClientProtocolException e){
mTextView.setText(e.getMessage().toString());
e.printStackTrace();
} catch (IOException e) {
mTextView.setText(e.getMessage().toString());
e.printStackTrace();
}catch(Exception e){
mTextView.setText(e.getMessage().toString());
e.printStackTrace();
}
}
}.start();
}
返回的数据是登陆界面的。网站用户名打开网页的时候已经有了 HttpGet --------------------编程问答-------------------- 应该没有问题,你添加网络访问了吗?
<uses-permission android:name="android.permission.INTERNET"/> --------------------编程问答-------------------- 楼主你确定传个password就能登陆吗? 你要先搞清楚他的登陆参数到底传什么 用fiddler拦截登陆的htpp请求 看下他登陆是如何传参的 然后再模拟登陆
补充:Java , Java相关