先上图,周第一,
月第六代码未整理,比较乱,仅仅供参考(cookie已经废了,号被封了,哈哈)
using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Net.Sockets;
using System.Text;
using System.Threading; namespace ConsoleApp
{
class HttpTest2
{
static string cookie = "Cookie: __gads=ID=1f8dc03afed075c6:T=1381988624:S=ALNI_MZ8iQ0NMreao4U_vBN_oDEnpgOxgw; pgv_pvi=5770902528; _JQCMT_ifcookie=1; _JQCMT_browser=b4439cc7f124ad87d874d68d5fc644cf; __message_district_code=350000; CNZZDATA5643930=cnzz_eid%3D846003309-1384408502-http%253A%252F%252Fdownload.csdn.net%26ntime%3D1384408502%26cnzz_a%3D0%26sin%3Dhttp%253A%252F%252Fwww.baidu.com%252Fs%253Fwd%253Dhighcharts%2525E4%2525B8%2525AD%2525E6%252596%252587api%2526rsp%253D5%2526f%253D1%2526oq%253Dhighcharts%2525E6%252595%252599%2525E7%2525A8%25258B%2526ie%253Dutf-8%2526rsv_ers%253Dxn0%2526rs_src%253D0%26ltime%3D1384408503620; _cnzz_CV=; __message_sys_msg_id=2170; pvz=mwaga6; pv4=mwagab; pv2=mwagae; pv7=mwagat; download_first=1; pvp=mwaglk; pvi=mwaglt; pv3=mwaglw; pvv=mwagm4; pvl=mwaigy; pvr=mwaim4; pvg=mwakhl; pvo=mwaki3; pvd=mwaki6; pvq=mwakid; pvj=mwakpr; pvk=mwakpx; pvs=mwakva; UserName=JGL5987; UserInfo=uUADWg%2f8ZUtNIrdt%2bofLnM52kQ%2bq%2bxW5f4TzH5l5ochikqs5AcDtwoDOfxN1PyB%2bUmv4YKJc0uVrotybh7QpXUKtlwRgQOA6n%2fdqh22aQvKfpjq%2fxjlhr2BYHxll47%2bH; UN=JGL5987; UserNick=JGL5987; access-token=282b5a25-85f8-48e6-8367-9339e8f76287; __utma=17226283.2019835236.1381978948.1384485052.1384490950.34; __utmb=17226283.116.10.1384490950; __utmc=17226283; __utmz=17226283.1384408503.31.17.utmcsr=baidu|utmccn=(organic)|utmcmd=organic|utmctr=highcharts%E4%B8%AD%E6%96%87api; pvn=mwakw6; __message_gu_msg_id=0; __message_cnel_msg_id=0; __message_in_school=0"; private static Socket ConnectSocket(string server, int port)
{
Socket s = null;
IPHostEntry hostEntry = null; // Get host related information.
hostEntry = Dns.GetHostEntry(server); // Loop through the AddressList to obtain the supported AddressFamily. This is to avoid
// an exception that occurs when the host IP Address is not compatible with the address family
// (typical in the IPv6 case).
foreach (IPAddress address in hostEntry.AddressList)
{
IPEndPoint ipe = new IPEndPoint(address, port);
Socket tempSocket =
new Socket(ipe.AddressFamily, SocketType.Stream, ProtocolType.Tcp); tempSocket.Connect(ipe); if (tempSocket.Connected)
{
s = tempSocket;
break;
}
else
{
continue;
}
}
return s;
} private static string SocketSendReceive(string request, string server, int port)
{ Byte[] bytesSent = Encoding.ASCII.GetBytes(request);
Byte[] bytesReceived = new Byte[256]; // 创建连接
Socket s = ConnectSocket(server, port); if (s == null)
return ("Connection failed"); // 发送内容.
s.Send(bytesSent, bytesSent.Length, 0); // Receive the server home page content.
int bytes = 0;
string page = "Default HTML page on " + server + ":\r\n"; //接受返回的内容.
do
{
bytes = s.Receive(bytesReceived, bytesReceived.Length, 0);
page = page + Encoding.UTF8.GetString(bytesReceived, 0, bytes);
}
while (bytes > 0); return page;
} internal static void Test2(List<string> idss)
{
//string[] ids = id.Split(';');
foreach (var i in idss)
{ string request = string.Format(@"GET http://download.csdn.net/index.php/comment/post_comment?jsonpcallback=jsonp1373334338283&sourceid={0}&content=%E5%AE%9E%E9%99%85%E6%B5%8B%E8%AF%95%E5%8F%AF%E4%BB%A5%E4%BD%BF%E7%94%A8%EF%BC%8C%E4%B8%8D%E9%94%99%E7%9A%84%E8%B5%84%E6%BA%90%EF%BC%8C%E6%84%9F%E8%B0%A2%E5%88%86%E4%BA%AB%2C&rating=5&t=1373334383005 HTTP/1.1
Host: download.csdn.net
Connection: Close
Accept: text/javascript, application/javascript, */*
X-Requested-With: XMLHttpRequest
User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/27.0.1453.116 Safari/537.36
Content-Type: application/x-www-form-urlencoded
Referer: http://download.csdn.net/detail/haide1014/4954667
Accept-Encoding: gzip,deflate,sdch
Accept-Language: zh-CN,zh;q=0.8,en-GB;q=0.6,en;q=0.4
{1} ", i, cookie); string host = "download.csdn.net";
int port = 80;
string result = SocketSendReceive(request, host, port);
Console.Write("ID为{0}的 ", i);
Console.WriteLine(result);
int n = new Random().Next(100);
Console.Title = (n + 61).ToString();
for (int j = 0; j < n + 61; j++)
{
Console.Write(j);
Thread.Sleep(1000);
}
} } internal static void Test()
{ Console.WriteLine("输入编号");
int n = Convert.ToInt32(Console.ReadLine());
switch (n)
{
case 7:
cookie = "Cookie: __gads=ID=1f8dc03afed075c6:T=1381988624:S=ALNI_MZ8iQ0NMreao4U_vBN_oDEnpgOxgw; pgv_pvi=5770902528; _JQCMT_ifcookie=1; _JQCMT_browser=b4439cc7f124ad87d874d68d5fc644cf; __message_district_code=350000; CNZZDATA5643930=cnzz_eid%3D846003309-1384408502-http%253A%252F%252Fdownload.csdn.net%26ntime%3D1384408502%26cnzz_a%3D0%26sin%3Dhttp%253A%252F%252Fwww.baidu.com%252Fs%253Fwd%253Dhighcharts%2525E4%2525B8%2525AD%2525E6%252596%252587api%2526rsp%253D5%2526f%253D1%2526oq%253Dhighcharts%2525E6%252595%252599%2525E7%2525A8%25258B%2526ie%253Dutf-8%2526rsv_ers%253Dxn0%2526rs_src%253D0%26ltime%3D1384408503620; _cnzz_CV=; __message_sys_msg_id=2170; pvz=mwaga6; pv4=mwagab; pv2=mwagae; pv7=mwagat; download_first=1; pvp=mwaglk; pvi=mwaglt; pv3=mwaglw; pvv=mwagm4; pvl=mwaigy; pvr=mwaim4; pvg=mwakhl; pvo=mwaki3; pvd=mwaki6; pvq=mwakid; pvj=mwakpr; pvk=mwakpx; pvs=mwakva; UserName=JGL5987; UserInfo=uUADWg%2f8ZUtNIrdt%2bofLnM52kQ%2bq%2bxW5f4TzH5l5ochikqs5AcDtwoDOfxN1PyB%2bUmv4YKJc0uVrotybh7QpXUKtlwRgQOA6n%2fdqh22aQvKfpjq%2fxjlhr2BYHxll47%2bH; UN=JGL5987; UserNick=JGL5987; access-token=282b5a25-85f8-48e6-8367-9339e8f76287; __utma=17226283.2019835236.1381978948.1384485052.1384490950.34; __utmb=17226283.116.10.1384490950; __utmc=17226283; __utmz=17226283.1384408503.31.17.utmcsr=baidu|utmccn=(organic)|utmcmd=organic|utmctr=highcharts%E4%B8%AD%E6%96%87api; pvn=mwakw6; __message_gu_msg_id=0; __message_cnel_msg_id=0; __message_in_school=0";
break; }
while (true)
{
List<string> idss = new List<string>();
int count = 0;
for (int i = 0; i < count + 1; i++)
{
Console.WriteLine(i);
string request = string.Format(@"GET http://download.csdn.net/my/downloads/{0} HTTP/1.1
Host: download.csdn.net
Connection: close
Cache-Control: max-age=0
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8
User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/32.0.1664.3 Safari/537.36
Accept-Language: zh-CN,zh;q=0.8,en-GB;q=0.6,en;q=0.4
{1} ", i, cookie);
string host = "download.csdn.net";
int port = 80;
string result = SocketSendReceive(request, host, port);
List<string> ids = RegExpHelper.Match(result, @"(?<=<a href=""/detail/.*?/)\d+(?=#)");
if (count == 0)
count = Convert.ToInt32(RegExpHelper.Match(result, @"(?<=共)\d*?(?=页)")[0]);
idss.AddRange(ids);
}
Console.WriteLine(idss.Count);
StringBuilder sb = new StringBuilder();
foreach (var a in idss)
{
sb.Append(a).Append(";");
Console.Write(a);
Console.Write(";");
}
Console.ReadKey();
Test2(idss);
}
} internal static void Test3(string url, string referer)
{
string request = string.Format(@"POST {0} HTTP/1.1
Host: download.csdn.net
Connection: close
Content-Length: 20
Cache-Control: max-age=0
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8
Origin: http://download.csdn.net
User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/32.0.1664.3 Safari/537.36
Content-Type: application/x-www-form-urlencoded
Referer: {1}
Accept-Encoding: gzip,deflate,sdch
Accept-Language: zh-CN,zh;q=0.8,en-GB;q=0.6,en;q=0.4
{2} ds=wt&validate_code=
", url, referer, cookie);
string host = "download.csdn.net";
int port = 80;
string result = SocketSendReceive(request, host, port);
Console.WriteLine(result);
//Console.ReadKey();
int n = new Random().Next(10);
Console.Title = (n + 20).ToString();
for (int j = 0; j < n + 20; j++)
{
Console.Write(j);
Thread.Sleep(1000);
}
} internal static void Test4()
{
Console.WriteLine("下载功能输入编号");
int n = Convert.ToInt32(Console.ReadLine());
switch (n)
{
case 7:
cookie = "Cookie: __gads=ID=1f8dc03afed075c6:T=1381988624:S=ALNI_MZ8iQ0NMreao4U_vBN_oDEnpgOxgw; pgv_pvi=5770902528; _JQCMT_ifcookie=1; _JQCMT_browser=b4439cc7f124ad87d874d68d5fc644cf; __message_district_code=350000; CNZZDATA5643930=cnzz_eid%3D846003309-1384408502-http%253A%252F%252Fdownload.csdn.net%26ntime%3D1384408502%26cnzz_a%3D0%26sin%3Dhttp%253A%252F%252Fwww.baidu.com%252Fs%253Fwd%253Dhighcharts%2525E4%2525B8%2525AD%2525E6%252596%252587api%2526rsp%253D5%2526f%253D1%2526oq%253Dhighcharts%2525E6%252595%252599%2525E7%2525A8%25258B%2526ie%253Dutf-8%2526rsv_ers%253Dxn0%2526rs_src%253D0%26ltime%3D1384408503620; _cnzz_CV=; __message_sys_msg_id=2170; pvz=mwaga6; pv4=mwagab; pv2=mwagae; pv7=mwagat; download_first=1; pvp=mwaglk; pvi=mwaglt; pv3=mwaglw; pvv=mwagm4; pvl=mwaigy; pvr=mwaim4; pvg=mwakhl; pvo=mwaki3; pvd=mwaki6; pvq=mwakid; pvj=mwakpr; pvk=mwakpx; pvs=mwakva; UserName=JGL5987; UserInfo=uUADWg%2f8ZUtNIrdt%2bofLnM52kQ%2bq%2bxW5f4TzH5l5ochikqs5AcDtwoDOfxN1PyB%2bUmv4YKJc0uVrotybh7QpXUKtlwRgQOA6n%2fdqh22aQvKfpjq%2fxjlhr2BYHxll47%2bH; UN=JGL5987; UserNick=JGL5987; access-token=282b5a25-85f8-48e6-8367-9339e8f76287; __utma=17226283.2019835236.1381978948.1384485052.1384490950.34; __utmb=17226283.116.10.1384490950; __utmc=17226283; __utmz=17226283.1384408503.31.17.utmcsr=baidu|utmccn=(organic)|utmcmd=organic|utmctr=highcharts%E4%B8%AD%E6%96%87api; pvn=mwakw6; __message_gu_msg_id=0; __message_cnel_msg_id=0; __message_in_school=0";
break; }
string xxoo = "ppt api 中文 jar包 html js收缩插件vs 课件 c++ mysql jdk ext 驱动jar包 采集器 java c# 数据库连接池 jad js jquery droiddraw 工具 jdbc 代码 nhibernate xml 解析 完整版 fiddler 网络神采 j2ee 常用jar包的含义 asp.net 课传智播客件 ssh2 myeclip 快捷键 viewstate java 常见异常整理 查看器 gui exe 合并软件 sql格式化 sqlpp dll sqlyog 端口查看器 msdn 查看器 插件 高级程序设计 表单验证插件 mygeneration 开发指南 node.js 深入浅出 wpf codesmith 5000招 电脑超级技巧 msi v0.10.4-x86 文档 3.5 xp win7 node 登录 破解 绿色 免费版 form tomcat struts2中文教程_ch.chm exil js收缩插件 vs 自定义控件 idea 匹配器 加解密工具 des 火车头 extjs 正则表达式 jquery-ui 0 dom4j spring2.5-中文参考手册 qq 韩顺平 素材 若水 游戏编程 从零开始 j2ee 嵌入式 学习笔记 数据库 界面设计 资源文件android.jar arm apktool 反编译 中科大 浙江大学 swing eclipse, 计算机组成答案 程序员考试 汇编 vb帮助文档 vb awt, 安卓 layout 布局 中文版 sql帮助文档 sdk 最强的文本编辑器 ue sqlite 三个jar 实例代码 android传智播客 mysql-5.5.18-win32.zip 韩顺平+学生管理系统+源码 oracle 大全 标签 log4j hibernate3.2 hibernate3.2_ch.chm servlet中文教程 log4j.jar jdom.jar struts2 dbentry xml解析 1.7 html官方原版 sqlserver2005 汉化包 数据库连接时 dbcp jdbc连接时 sql2000 c3p0 eclipse 编程基本规范 junit hamcrest php 编程规范 谭浩强 帮助文档";
string[] gjz = xxoo.Split(' ');
foreach (var g in gjz)
{
for (int i = 1; i <= 10; i++)
{
string request = string.Format(@"GET http://download.csdn.net/search?sort=&title={0}&body=&user_name=&tag=&categoryid=&source_money=0-0&created_at=&per_page={1} HTTP/1.1
Host: download.csdn.net
Connection: close
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8
User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/32.0.1664.3 Safari/537.36
Referer: http://download.csdn.net/search?sort=&title=c%23&body=&user_name=&tag=&categoryid=&source_money=0-0&created_at=&per_page=2
Accept-Language: zh-CN,zh;q=0.8,en-GB;q=0.6,en;q=0.4
{2} ", g, i, cookie);
string host = "download.csdn.net";
int port = 80;
string result = SocketSendReceive(request, host, port);
var list = RegExpHelper.Match(result, "(?<=>)http://download.csdn.net/detail.*?(?=<)");
foreach (var item in list)
{
string url = item.Replace("detail", "download");
string request2 = string.Format(@"GET {0} HTTP/1.1
Host: download.csdn.net
Connection: close
Cache-Control: max-age=0
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8
User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/32.0.1664.3 Safari/537.36
Accept-Language: zh-CN,zh;q=0.8,en-GB;q=0.6,en;q=0.4
{1} ", url, cookie);
string host2 = "download.csdn.net";
int port2 = 80;
string result2 = SocketSendReceive(request2, host2, port2);
var downUrl = RegExpHelper.Match(result2, @"http://download.csdn.net/index.php.*?(?="")");
//Console.WriteLine(downUrl[0]);
//Console.ReadKey();
if(downUrl.Count > 0)
Test3(downUrl[0], url);
} }
}
}
}
}