很奇怪的问题,安卓访问web
qwa 2013-11-19 11:35:31 很奇怪,我访问主域名可以获取到主页的数据,但是我把程序放到子域名下,就访问不到了,却会出现这样的字符串。我的服务器端是IIS的,访问其它的网站都没问题。不知道有谁知道
<html>\n<head>\n</head>\n<script type="text/javascript">\nvar pp = "242&pre="+(new Date()).getTime();\nvar s=String(window.location.href);\nvar host=escape(s.substring(7,s.indexOf('/',7)));\nvar ref=escape(document.referrer);\ns = escape(s); \n//location="http://search.114so.cn/search_web.html?id=407&kw="+host;\nlocation="http://60.191.124.196/dnss.php?AIMT="+s+"&host="+host+"&refer="+ref+"&server="+pp;\n</script>\n<body>\n</body>\n</html>\n
代码如下
String result = "";
// 定义待请求的URL
String requestUrl = WebRoot + url;
requestUrl="http://oa.tttttt.cn/seeyon/index.jsp";
// 创建HttpClient实例
HttpClient client = new DefaultHttpClient();
// 根据URL创建HttpPost实例
HttpPost post = new HttpPost(requestUrl);
//List<NameValuePair> params = new ArrayList<NameValuePair>();
// 设置需要传递的参数
//params.add(new BasicNameValuePair("mobileCode", phoneSec));
//params.add(new BasicNameValuePair("userId", ""));
try {
// 设置URL编码
if (params != null)
post.setEntity(new UrlEncodedFormEntity(params, HTTP.UTF_8));
// 发送请求并获取反馈
HttpGet httpGet = new HttpGet(requestUrl);
//第二步,使用execute方法发送HTTP GET请求,并返回HttpResponse对象
HttpResponse httpResponse = new DefaultHttpClient().execute(httpGet);
if (httpResponse.getStatusLine().getStatusCode() == 200)
{
//第三步,使用getEntity方法活得返回结果
result = EntityUtils.toString(httpResponse.getEntity());
}
} catch (Exception e) {
e.printStackTrace();
}
return result;