高分求C#/WinForm下模拟网页登录后获取信息的源代码或者思路 用数组或者哈西表作为全局静态变量保存登陆者名单,判断时看看数组中是否存在可用Panel作为控件,图片的容器,到时候,如果登陆 则visiable 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 //在窗体一适当位置加入private static string username,flag;Mainfrm mainfrm = new Mainfrm(username,flag);mainfrm.Show();//窗体二适当位置加入public string user,type;public Mainfrm(string username, string flag){ user = username; type = flag;}//基本思想是给窗体二设置适当参数,有窗体一传递过来 晕 看来大家误会我的意思了 我不是要判断某个用户登录时候又没有权限举例说吧:我是要登录一个不属于我的论坛,用户名和密码我都有我要在winform C#窗体里面实现登录后 在用sockets或者webrequest等方式获取没有登录前被Session或者cookies保护的页面信息 你可以到下面去找一个叫CSDN论坛助手的东东...某高手写的,记不起名字了.上面可能有你想要的资料吧,有源码的.ftp://qydn.vicp.net/ftp://211.140.160.74哪个我记不太清了,你去找下吧...如果没有了把你的Email告诉我,我给你发一个 using System;using System.IO;using System.Net;using System.Runtime.CompilerServices;using System.Text;using System.Web;namespace MyCommon{ /// <summary> /// MyHTML 的摘要说明。 /// </summary> public class MyHTML { private string cookieContainer=""; public string CookieContainer { get { return cookieContainer; } set { cookieContainer = value; } } public string Login(string url, string paramList) { HttpWebResponse httpWebResponse=null; try { HttpWebRequest httpWebRequest = (HttpWebRequest)HttpWebRequest.Create(url); httpWebRequest.Method = "POST"; httpWebRequest.ContentType = "application/x-www-form-urlencoded"; httpWebRequest.AllowAutoRedirect = false; CookieContainer c = new CookieContainer(); httpWebRequest.CookieContainer = c; StringBuilder sb= new StringBuilder(); char[] ch = new char[]{'?', '=', '&'}; if (paramList != null) { int j; for (int i = 0; i < paramList.Length; i = j + 1) { j = paramList.IndexOfAny(ch, i); if (j == -1) { sb.Append(HttpUtility.UrlEncode(paramList.Substring(i))); break; } else { sb.Append(HttpUtility.UrlEncode(paramList.Substring(i, j - i))); sb.Append(paramList.Substring(j, 1)); } } byte [] b = Encoding.Default.GetBytes(sb.ToString()); httpWebRequest.ContentLength = b.Length; Stream s = httpWebRequest.GetRequestStream(); s.Write(b, 0, b.Length); s.Close(); } else { httpWebRequest.ContentLength = 0; } httpWebResponse = (HttpWebResponse)httpWebRequest.GetResponse(); cookieContainer = httpWebRequest.CookieContainer.GetCookieHeader(new Uri(url)); } catch (Exception e) { return e.Message; } finally { if (httpWebResponse != null) { httpWebResponse.Close(); } } return cookieContainer; } public string GetHTMLPage(string url, string paramList) { HttpWebResponse httpWebResponse=null; StringBuilder getHTMLPage = new StringBuilder(); try { HttpWebRequest httpWebRequest = (HttpWebRequest)WebRequest.Create(url); httpWebRequest.Method = "POST"; httpWebRequest.KeepAlive = true; httpWebRequest.ContentType = "application/x-www-form-urlencoded"; CookieContainer c = new CookieContainer(); httpWebRequest.CookieContainer = c; httpWebRequest.CookieContainer.SetCookies(new Uri(url), cookieContainer); StringBuilder sb = new StringBuilder(); char[] ch = new char[]{'?', '=', '&'}; if (paramList != null) { int j; for (int i = 0; i < paramList.Length; i = j + 1) { j = paramList.IndexOfAny(ch, i); if (j == -1) { sb.Append(HttpUtility.UrlEncode(paramList.Substring(i))); break; } else { sb.Append(HttpUtility.UrlEncode(paramList.Substring(i, j - i))); sb.Append(paramList.Substring(j, 1)); } } byte[] b = Encoding.Default.GetBytes(sb.ToString()); httpWebRequest.ContentLength = b.Length; Stream s = httpWebRequest.GetRequestStream(); s.Write(b, 0, b.Length); s.Close(); } else { httpWebRequest.ContentLength = 0; } httpWebResponse = (HttpWebResponse)httpWebRequest.GetResponse(); StreamReader sr = new StreamReader(httpWebResponse.GetResponseStream(), Encoding.Default); getHTMLPage.Append(sr.ReadToEnd()); } catch (Exception e) { getHTMLPage.Append(e.ToString()); } finally { if (httpWebResponse != null) { httpWebResponse.Close(); } } return getHTMLPage.ToString(); } }} DrawRectangle为什么会差一个像素? [数据查询] 模糊查询 一段绘制图片代码的问题 vs2005做的程序怎么发布呀?不用智能客户端部署 datagrid的很难的问题 关闭窗口的问题 方法可不可以返回整个一个数组? DataTable 到底是存放在哪里? 请教,在线等待 请问水晶 报表是个什么东西啊 http/1.1 500 internal server error 怎样把XML文件的ElementName都变成小写的?
private static string username,flag;
Mainfrm mainfrm = new Mainfrm(username,flag);
mainfrm.Show();
//窗体二适当位置加入
public string user,type;
public Mainfrm(string username, string flag)
{
user = username;
type = flag;
}
//基本思想是给窗体二设置适当参数,有窗体一传递过来
上面可能有你想要的资料吧,有源码的.
ftp://qydn.vicp.net/ftp://211.140.160.74
哪个我记不太清了,你去找下吧...如果没有了把你的Email告诉我,我给你发一个
using System.IO;
using System.Net;
using System.Runtime.CompilerServices;
using System.Text;
using System.Web;namespace MyCommon
{
/// <summary>
/// MyHTML 的摘要说明。
/// </summary>
public class MyHTML
{
private string cookieContainer="";
public string CookieContainer
{
get
{
return cookieContainer;
}
set
{
cookieContainer = value;
}
} public string Login(string url, string paramList)
{
HttpWebResponse httpWebResponse=null;
try
{
HttpWebRequest httpWebRequest = (HttpWebRequest)HttpWebRequest.Create(url);
httpWebRequest.Method = "POST";
httpWebRequest.ContentType = "application/x-www-form-urlencoded";
httpWebRequest.AllowAutoRedirect = false;
CookieContainer c = new CookieContainer();
httpWebRequest.CookieContainer = c;
StringBuilder sb= new StringBuilder();
char[] ch = new char[]{'?', '=', '&'};
if (paramList != null)
{
int j;
for (int i = 0; i < paramList.Length; i = j + 1)
{
j = paramList.IndexOfAny(ch, i);
if (j == -1)
{
sb.Append(HttpUtility.UrlEncode(paramList.Substring(i)));
break;
}
else
{
sb.Append(HttpUtility.UrlEncode(paramList.Substring(i, j - i)));
sb.Append(paramList.Substring(j, 1));
}
}
byte [] b = Encoding.Default.GetBytes(sb.ToString());
httpWebRequest.ContentLength = b.Length;
Stream s = httpWebRequest.GetRequestStream();
s.Write(b, 0, b.Length);
s.Close();
}
else
{
httpWebRequest.ContentLength = 0;
}
httpWebResponse = (HttpWebResponse)httpWebRequest.GetResponse();
cookieContainer = httpWebRequest.CookieContainer.GetCookieHeader(new Uri(url));
}
catch (Exception e)
{
return e.Message;
}
finally
{
if (httpWebResponse != null)
{
httpWebResponse.Close();
}
}
return cookieContainer;
} public string GetHTMLPage(string url, string paramList)
{
HttpWebResponse httpWebResponse=null;
StringBuilder getHTMLPage = new StringBuilder();
try
{
HttpWebRequest httpWebRequest = (HttpWebRequest)WebRequest.Create(url);
httpWebRequest.Method = "POST";
httpWebRequest.KeepAlive = true;
httpWebRequest.ContentType = "application/x-www-form-urlencoded";
CookieContainer c = new CookieContainer();
httpWebRequest.CookieContainer = c;
httpWebRequest.CookieContainer.SetCookies(new Uri(url), cookieContainer);
StringBuilder sb = new StringBuilder();
char[] ch = new char[]{'?', '=', '&'};
if (paramList != null)
{
int j;
for (int i = 0; i < paramList.Length; i = j + 1)
{
j = paramList.IndexOfAny(ch, i);
if (j == -1)
{
sb.Append(HttpUtility.UrlEncode(paramList.Substring(i)));
break;
}
else
{
sb.Append(HttpUtility.UrlEncode(paramList.Substring(i, j - i)));
sb.Append(paramList.Substring(j, 1));
}
}
byte[] b = Encoding.Default.GetBytes(sb.ToString());
httpWebRequest.ContentLength = b.Length;
Stream s = httpWebRequest.GetRequestStream();
s.Write(b, 0, b.Length);
s.Close();
}
else
{
httpWebRequest.ContentLength = 0;
}
httpWebResponse = (HttpWebResponse)httpWebRequest.GetResponse();
StreamReader sr = new StreamReader(httpWebResponse.GetResponseStream(), Encoding.Default);
getHTMLPage.Append(sr.ReadToEnd());
}
catch (Exception e)
{
getHTMLPage.Append(e.ToString());
}
finally
{
if (httpWebResponse != null)
{
httpWebResponse.Close();
}
}
return getHTMLPage.ToString();
}
}
}