主要是想做一个软件,不用打开网站,从数据库中将里面的文章分别发至不同的网站
当然,是我自己弄得网站
我看到很多自动发帖机软件。论坛群发什么的都是这个原理不过感觉比较麻烦,我这里是自己的,就免去验证码识别等复杂技术了
只要完成登录,发贴,退出,登录下一个网站,发贴,退出。下面是我抓的数据包,作为例子首先是登录POST /user.asp?Action=chklogin HTTP/1.1
Accept: image/gif, image/x-xbitmap, image/jpeg, image/pjpeg, application/x-shockwave-flash, application/vnd.ms-excel, application/vnd.ms-powerpoint, application/msword, */*
Referer: http://localhost/user.asp
Accept-Language: zh-cn
Content-Type: application/x-www-form-urlencoded
Accept-Encoding: gzip, deflate
User-Agent: Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; .NET CLR 2.0.50727)
Host: localhost
Content-Length: 72
Connection: Keep-Alive
Cache-Control: no-cache
Cookie: VFGNLVCWIGESOGSOGQOG=RVFBSTEJMIBASYKZGOZWTHEGYCCJAZOEABGVDICO; DreamSun_Post_tieba200=; AJSTAT_ok_times=3; AJSTAT_ok_pages=13username=admin&pwd=admin&zd_code=5864&baoliu=&comurl=&login=%B5%C7%C2%BCHTTP/1.1 200 OK
Server: NetBox Version 2.8 Build 4128
Date: Sun, 11 Apr 2010 14:28:00 GMT
Connection: Keep-Alive
Set-Cookie: DreamSun_Post_tieba200=username=admin&rnd=shqdxsm5crdg4hj02o; path=/
Cache-control: private
Content-Type: text/html
Content-Length: 1460<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gbk" />
<title>会员中心-追梦阳光贴吧官方网站</title>
<meta name="Copyright" content="追梦阳光动力" />
<meta name="keywords" content="追梦阳光贴吧 专业程序开发制作" />
<meta name="description" content="追梦阳光贴吧2.0是一款短小精悍的ASP信息资讯发布展示系统,他集成了留言本的便捷,CMS的实用,论坛的交互性于一体。" />
<link href="skins/200/style.css" rel="stylesheet" type="text/css" />
<script type="text/javascript" src="images/jquery-1.3.2.min.js"></script>
<script type="text/javascript" src="images/js.js"></script>
</head>
<body>
<div id="header">
<div class="wrap s_clear">
<h2><a href="index.asp"><img src="skins/200/logo.png" border="0" /></a></h2>
<div id="umenu"><A href='user.asp'>登录</A> | <A href='user.asp?Action=reg'>注册</A> | <a href='user.asp?Action=restorePwd' title='按此找回密码'>忘记密码?</a></div>
<div id="ad_headerbanner">TieBa_AD_Top<!-- 广告位置 --></div>
<div id="menu">
<ul></ul>
</div>
</div>
</div>
<div id="nav"><span><ul></ul></span><div id="navpr"><a href="index.asp">追梦阳光贴吧官方网站</a> &raquo; 会员中心</div></div>
<div id="wrapper" class="wrap s_clear">
<script>alert('恭喜,登录成功!当前积分17分');window.location.replace('index.asp');</Script>这个是发贴的数据包POST /tzsave.asp?cz=addsave HTTP/1.1
Accept: image/gif, image/x-xbitmap, image/jpeg, image/pjpeg, application/x-shockwave-flash, application/vnd.ms-excel, application/vnd.ms-powerpoint, application/msword, */*
Referer: http://localhost/index.asp
Accept-Language: zh-cn
Content-Type: application/x-www-form-urlencoded
Accept-Encoding: gzip, deflate
User-Agent: Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; .NET CLR 2.0.50727)
Host: localhost
Content-Length: 169
Connection: Keep-Alive
Cache-Control: no-cache
Cookie: VFGNLVCWIGESOGSOGQOG=RVFBSTEJMIBASYKZGOZWTHEGYCCJAZOEABGVDICO; DreamSun_Post_tieba200=username=admin&rnd=shqdxsm5crdg4hj02o; AJSTAT_ok_times=3; AJSTAT_ok_pages=17BoardId=2&isRe=1&title=%B2%E2%CA%D4&titleBold=0&titlecolor=&content=%B2%E2%CA%D4%C4%DA%C8%DD%B7%B4%B7%B4%B8%B4%B8%B4%B7%B4%B7%B4%B8%B4%B8%B4%B7%A2%B7%A2&zd_code=dreamsunHTTP/1.1 200 OK
Server: NetBox Version 2.8 Build 4128
Date: Sun, 11 Apr 2010 14:31:14 GMT
Connection: Keep-Alive
Cache-control: private
Content-Type: text/html
Content-Length: 106<script>alert('恭喜您!帖子发表成功,您获得发帖积分2分');window.location.replace('show.asp?id=7');</Script>
GET /show.asp?id=7 HTTP/1.1
Accept: image/gif, image/x-xbitmap, image/jpeg, image/pjpeg, application/x-shockwave-flash, application/vnd.ms-excel, application/vnd.ms-powerpoint, application/msword, */*
Accept-Language: zh-cn
Accept-Encoding: gzip, deflate
User-Agent: Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; .NET CLR 2.0.50727)
Host: localhost
Connection: Keep-Alive
Cookie: VFGNLVCWIGESOGSOGQOG=RVFBSTEJMIBASYKZGOZWTHEGYCCJAZOEABGVDICO; DreamSun_Post_tieba200=username=admin&rnd=shqdxsm5crdg4hj02o; AJSTAT_ok_times=3; AJSTAT_ok_pages=17HTTP/1.1 200 OK
Server: NetBox Version 2.8 Build 4128
Date: Sun, 11 Apr 2010 14:31:21 GMT
Connection: Keep-Alive
Cache-control: private
Content-Type: text/html
Content-Length: 6069<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gbk" />
<title>测试-站长交易-追梦阳光贴吧官方网站</title>
<meta name="Copyright" content="追梦阳光动力" />
<meta name="keywords" content="测试,站长交易,追梦阳光贴吧官方网站,追梦阳光贴吧 专业程序开发制作" />
<meta name="description" content="追梦阳光贴吧2.0是一款短小精悍的ASP信息资讯发布展示系统,他集成了留言本的便捷,CMS的实用,论坛的交互性于一体。" />
<link href="skins/200/style.css" rel="stylesheet" type="text/css" />
<script type="text/javascript" src="images/jquery-1.3.2.min.js"></script>
<script type="text/javascript" src="images/js.js"></script>
</head>
<body>代码太长了,把返回的网页内容删除了

</body>
</html>GET /go.asp?svid=4&id=3492964&tpages=18&ttimes=3&tzone=8&tcolor=32&sSize=1024,768&referrer=&vpage=http%3A//localhost/show.asp%3Fid%3D7 HTTP/1.1
Accept: */*
Referer: http://localhost/show.asp?id=7
Accept-Language: zh-cn
Accept-Encoding: gzip, deflate
User-Agent: Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; .NET CLR 2.0.50727)
Host: web1.51.la:82
Connection: Keep-AliveHTTP/1.1 200 OK
Date: Sun, 11 Apr 2010 14:31:22 GMT
Server: Microsoft-IIS/6.0
Content-Length: 0
Content-Type: text/html
Expires: Sat, 10 Apr 2010 21:51:22 GMT
Cache-control: private
GET /ajax.asp?a=get_msg_num&b=0.5419377791476334 HTTP/1.1
x-requested-with: XMLHttpRequest
Accept-Language: zh-cn
Referer: http://localhost/show.asp?id=7
Accept: text/html, */*
Accept-Encoding: gzip, deflate
User-Agent: Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; .NET CLR 2.0.50727)
Host: localhost
Connection: Keep-Alive
Cookie: VFGNLVCWIGESOGSOGQOG=RVFBSTEJMIBASYKZGOZWTHEGYCCJAZOEABGVDICO; DreamSun_Post_tieba200=username=admin&rnd=shqdxsm5crdg4hj02o; AJSTAT_ok_times=3; AJSTAT_ok_pages=18HTTP/1.1 200 OK
Server: NetBox Version 2.8 Build 4128
Date: Sun, 11 Apr 2010 14:31:21 GMT
Connection: Keep-Alive
Cache-control: private
Content-Type: text/html;charset=gb2312
Content-Length: 0
[/code]

解决方案 »

  1.   

    不知道用什么发送,我看到大多数人说是winsock
    还有说 WebRequest 的
    谁能给个详细的源代码啊
      

  2.   

    这个无非就是发送HTTP数据包, 但必须进行分析。如果发贴的过程不复杂的话还好,可能比较容易实现,但要麻烦一点的话就不容易了。发送HTTP包嘛, 说容易也容易,说难也难。 本人也曾经试过自过自动发博的工具,但最后因为中途有其他的事就不了了之了。说说如何发送HTTP包吧,可以用Winsock, 也可以用CInternetSession。CInternetSession是MFC中有的类,用起来是可以,不过有些东西用得不怎么顺手就是了。而Winsock呢,这个网上有用纯C++写的封装了HTTP操作的类,还是蛮不错的,如果觉得功能不能满足需要的话,可以稍加改善一下。但是如果比较懒的话,建议还是用CInternetSession,可以省去好多事。
      

  3.   

    我没有写过,但我想原理应该是这样。首先登录(提交URL,POST/GET 看具体代码),然后获得Cookie,接着就是提交HTTP的头信息,下面附带上Cookie~ Cookie跟你的登录后的Session有一定的关联(我这样认为的),因为HTTP和浏览器直接的连接不是一直保存,他们之间的关系是“一夜情”的关系,双方获得想要的东西,就断开连接了(有的服务器也支持一直保持连接)。所以服务器如何判断该登录用户的Session呢?就是根据Cookie吧~ 所以你可以试试将Cookie跟HTTP头一起发送过去。具体如何实现,你可以参考http://topic.csdn.net/u/20100411/12/1e93d23e-b441-426d-8088-488755cd9211.html 这篇上面的源码~ 呵呵~