本来某网站是 以参数传递日期的, 然后可以查到某日期的一个页面,我再正则取自己要的东西。如今人家改版了,把日期栏变成了表单传输的, 我该怎么只用超链接过去,顺便能传递这个 日期参数??
解决方案 »
- 关于三层中互相引用的问题
- 新闻发布系统的文档字段该用什么类型(Oracle)?
- 求助
- 在SQLHelper 中如何使用带事务处理的存储过程?
- 关于 HttpPostedFile 批量上传文件的问题
- 用.NET开发了一个特别适合于政府用的办公自动化OA系统,请大家感受一下。
- aspnet怎样实现象msn一样的功能
- xmlhttp提交后怎么保存到服务器
- 如何用CustomValidator去验证dropdownlist的选定值不为0
- 怎么样把excel从asp.net导入数据库中去,请教!
- 高分求:Telerik:RadMap 如何自定义地图供应商。
- 能否在后台获取input type="text"的title
HttpWebRequest wr = (HttpWebRequest)HttpWebRequest.Create("http://www.safe.gov.cn/AppStructured/view/project_syRMBQuery.action");
try
{
using (StreamReader sr = new StreamReader(wr.GetResponse().GetResponseStream(), Encoding.GetEncoding(936)))
{
htmlBody = sr.ReadToEnd();
}
}
catch
{
} 我的代码, 请指教该如何做,那个link是有效的
HttpWebRequest req = (HttpWebRequest)WebRequest.Create(url);
req.KeepAlive = false;
req.Method = "POST";
req.UserAgent = "Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.2; .NET CLR 1.1.4322; .NET CLR 2.0.50727)";
req.Credentials = CredentialCache.DefaultCredentials;
Encoding encode = new UTF8Encoding();
using (Stream stream = req.GetRequestStream())
{
Dictionary<string, string> nvc = new Dictionary<string, string>();
nvc.Add("Content", HttpUtility.UrlEncode(content, encode));
nvc.Add("Type", "1");
nvc.Add("StartDate", DateTime.Now.AddDays(-1).Date.ToString("yyyy-MM-dd 00:00:00"));
nvc.Add("EndDate", DateTime.Now.Date.ToString("yyyy-MM-dd 00:00:00"));
string boundary = "---------------------------" + DateTime.Now.Ticks.ToString("x");
byte[] boundarybytes = Encoding.ASCII.GetBytes("\r\n--" + boundary + "\r\n");
req.ContentType = "multipart/form-data; boundary=" + boundary;
string formdataTemplate = "Content-Disposition: form-data; name=\"{0}\"\r\n\r\n{1}";
foreach (string key in nvc.Keys)
{
stream.Write(boundarybytes, 0, boundarybytes.Length);
string formitem = string.Format(formdataTemplate, key, nvc[key]);
byte[] formitembytes = encode.GetBytes(formitem);
stream.Write(formitembytes, 0, formitembytes.Length);
}
stream.Write(boundarybytes, 0, boundarybytes.Length);
byte[] trailer = Encoding.ASCII.GetBytes("\r\nContent-Type: application/x-form-www-urlencoded\r\n\r\n\r\n--" + boundary + "--\r\n");
stream.Write(trailer, 0, trailer.Length);
} WebResponse res = req.GetResponse();
StreamReader sr = new StreamReader(res.GetResponseStream(), encode);
string result = sr.ReadToEnd();