110,536
社区成员
发帖
与我相关
我的任务
分享
static void downit(string strKey)
{
string postdata = buildPostdata(strKey);
byte[] data = Encoding.UTF8.GetBytes(postdata);
int cacheLength = 1024;
byte[] b = new byte[cacheLength];
HttpWebRequest wq = (HttpWebRequest)WebRequest.Create(new Uri("http://jandown.com/fetch.php"));
wq.Referer = "http://jandown.com";
wq.Method = "POST";
wq.ContentType = "multipart/form-data; boundary=---------------------------7dd3d9c1c1326";
wq.Accept = "*/*";
wq.UserAgent = "Mozilla/5.0 (compatible; MSIE 10.0; Windows NT 6.1; Trident/6.0)";
wq.ContentLength = postdata.Length;
try
{
Stream rs = wq.GetRequestStream();
rs.Write(data, 0, data.Length);
//rs.Close();
HttpWebResponse wr = (HttpWebResponse)wq.GetResponse();
Stream ws = wr.GetResponseStream();
FileStream sw = File.Create(strKey + ".torrent");
int intReadlen = 0;
while ((intReadlen = ws.Read(b, 0, cacheLength)) > 0)
{
sw.Write(b, 0, intReadlen);
}
sw.Close();
ws.Close();
rs.Close();
}
catch (Exception e)
{
Console.WriteLine(e.Message);
}
}
static string buildPostdata(string strKey)
{
StringBuilder sb = new StringBuilder();
sb.Append("-----------------------------7dd3d9c1c1326\r\nContent-Disposition: form-data; name=\"code\"\r\n\r\n").Append(strKey).Append("\r\n")
.Append("-----------------------------7dd3d9c1c1326\r\nContent-Disposition: form-data; name=\"action\"\r\n\r\ndownload-----------------------------7dd3d9c1c1326--");
return sb.ToString();
}