http://www.sufeinet.com/plugin.php?id=keke_group

苏飞论坛

 找回密码
 马上注册

QQ登录

只需一步,快速开始

分布式系统框架(V2.0) 轻松承载百亿数据,千万流量!讨论专区 - 源码下载 - 官方教程

HttpHelper爬虫框架(V2.7-含.netcore) HttpHelper官方出品,爬虫框架讨论区 - 源码下载 - 在线测试和代码生成

HttpHelper爬虫类(V2.0) 开源的爬虫类,支持多种模式和属性 源码 - 代码生成器 - 讨论区 - 教程- 例子

查看: 3207|回复: 5

[例子] 怪网,能登陆不能发贴,非一般的怪网!!

[复制链接]
发表于 2013-12-30 16:05:10 | 显示全部楼层 |阅读模式
[C#] 纯文本查看 复制代码
namespace WindowsFormsApplication1
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

       public  string cookie = "";
        //创建HTTP访问类对象
        HttpHelper http = new HttpHelper();
        HttpItem item = null;



        public static string URLDecode(string text)
        {
            return HttpUtility.UrlDecode(text, Encoding.GetEncoding("utf-8"));
        }
        public static string URLEncode(string text)
        {
            return HttpUtility.UrlEncode(text, Encoding.GetEncoding("utf-8"));
        }
      


        private void button3_Click(object sender, EventArgs e)  // 测试正常
        {



             HttpHelper http = new HttpHelper();
            HttpItem item = new HttpItem()
            {
                URL = "http://passport1.china.com/user/passportLogon.do?username=%E4%B8%AD%E5%9B%BD%E9%A6%96%E9%A2%862011&password=123456&cookietime=-1&cookietime=-1&callback=china_api_login_login.callback",//URL     必需项  
                Method = "GET",//URL     可选项 默认为Get  
                Timeout = 100000,//连接超时时间     可选项默认为100000  
                ReadWriteTimeout = 30000,//写入Post数据超时时间     可选项默认为30000  
                IsToLower = false,//得到的HTML代码是否转成小写     可选项默认转小写  
                Cookie = "",//字符串Cookie     可选项  
                UserAgent = "Mozilla/5.0 (compatible; MSIE 9.0; Windows NT 6.1; Trident/5.0; BOIE9;ZHCN)",//用户的浏览器类型,版本,操作系统     可选项有默认值  
                Accept = "application/javascript, */*;q=0.8",//    可选项有默认值  
                ContentType = " text/html; charset=UTF-8",//返回类型    可选项有默认值  
           //     Postdata = "formhash=77009dc2&referer=http%3A%2F%2Fwww.i0532.net%2Findex.php&loginfield=username&username=%B4%F3%BC%D2%BA%C3&password=wqjihqtqk&questionid=0&answer=",//Post数据     可选项GET时不需要写  
                Allowautoredirect = false
            };
            HttpResult result = http.GetHtml(item);
            string html = result.Html;
             cookie = result.Cookie;

           //  webBrowser1.DocumentText += html;
             richTextBox2.Text = html;






            //登录成功后进行测试
            item = new HttpItem()
            {
                URL = "http://club.china.com/data/threads/1011",//URL   
                Method = "get",//URL     可选项 默认为Get
                Cookie = cookie//当前登录Cookie
            };
            //得到HTML代码
             result = http.GetHtml(item);
            string  html2 = result.Html; 
             cookie = result.Cookie;

             richTextBox1.Text = html2;


             webBrowser1.DocumentText = richTextBox1.Text;



        }



    }




===================================================

   飞哥帮忙看看!!!谢谢啊



1. 开通SVIP会员,免费下载本站所有源码,不限次数据,不限时间
2. 加官方QQ群,加官方微信群获取更多资源和帮助
3. 找站长苏飞做网站、商城、CRM、小程序、App、爬虫相关、项目外包等点这里
发表于 2013-12-30 16:10:09 | 显示全部楼层
我好像没看到你发帖子的代码吗?
 楼主| 发表于 2013-12-30 16:39:30 | 显示全部楼层

             HttpHelper http = new HttpHelper();
            HttpItem item = new HttpItem()
            {
                URL = "http://passport1.china.com/user/passportLogon.do?username=%E4%B8%AD%E5%9B%BD%E9%A6%96%E9%A2%862011&password=123456&cookietime=-1&cookietime=-1&callback=china_api_login_login.callback",//URL     必需项  
                Method = "GET",//URL     可选项 默认为Get  
                Timeout = 100000,//连接超时时间     可选项默认为100000  
                ReadWriteTimeout = 30000,//写入Post数据超时时间     可选项默认为30000  
                IsToLower = false,//得到的HTML代码是否转成小写     可选项默认转小写  
                Cookie = "",//字符串Cookie     可选项  
                UserAgent = "Mozilla/5.0 (compatible; MSIE 9.0; Windows NT 6.1; Trident/5.0; BOIE9;ZHCN)",//用户的浏览器类型,版本,操作系统     可选项有默认值  
                Accept = "application/javascript, */*;q=0.8",//    可选项有默认值  
                ContentType = " text/html; charset=UTF-8",//返回类型    可选项有默认值  
           //     Postdata = "formhash=77009dc2&referer=http%3A%2F%2Fwww.i0532.net%2Findex.php&loginfield=username&username=%B4%F3%BC%D2%BA%C3&password=wqjihqtqk&questionid=0&answer=",//Post数据     可选项GET时不需要写  
                Allowautoredirect = false
            };
            HttpResult result = http.GetHtml(item);
            string html = result.Html;
             cookie = result.Cookie;

           //  webBrowser1.DocumentText += html;
             richTextBox2.Text = html;






            //登录成功后进行测试
            item = new HttpItem()
            {
                URL = "http://club.china.com/data/threads/1011",//URL     必需项,比如输入http://www.i0532.net/forum-85-1.html 供求信息板块
                Method = "get",//URL     可选项 默认为Get
                Cookie = cookie//当前登录Cookie
            };
            //得到HTML代码
             result = http.GetHtml(item);
            string  html2 = result.Html;
             cookie = result.Cookie;

             richTextBox1.Text = html2;


             webBrowser1.DocumentText = richTextBox1.Text;


 楼主| 发表于 2013-12-30 16:40:45 | 显示全部楼层
飞哥看看,POST不行,难道要用元素赋值
发表于 2013-12-30 16:43:42 | 显示全部楼层
你这只有登录代码,那有发帖子的代码呀,你发这和一楼的不是一样的吗?
 楼主| 发表于 2013-12-30 19:21:30 | 显示全部楼层
  private void button2_Click(object sender, EventArgs e)
        {


            HttpItem item = new HttpItem()
            {
                URL = "http://r.club.china.com/controler.do?event=PUBOLDCOMMONFORUMSQUICK&forumid=1011&threadid=276694308&quickPictureUrl=&submiTime=",//URL     必需项   
                Encoding = System.Text.Encoding.GetEncoding("gbk"),//URL     可选项 默认为Get   
                Method = "post",//URL     可选项 默认为Get   
                Cookie = cookie, //字符串Cookie     直接用第一次GET到的cookie
                Referer = "http://club.china.com/data/thread/1011/2766/94/30/8_1.html",//来源URL     可选项   
                Postdata = "body=测试&domain=http://club.china.com/data/thread/1011/2766/94/30/8_1.html",//Post数据     
                Timeout = 100000,//连接超时时间     可选项默认为100000   
                ReadWriteTimeout = 30000,//写入Post数据超时时间     可选项默认为30000   
                UserAgent = "Mozilla/5.0 (compatible; MSIE 9.0; Windows NT 6.1; WOW64; Trident/5.0; KB974488)",//用户的浏览器类型,版本,操作系统     可选项有默认值   
                ContentType = "multipart/form-data; boundary=---------------------------7dd33b1780600",//返回类型    可选项有默认值   

            };
            HttpResult result = http.GetHtml(item);
            result = http.GetHtml(item);
            string html = result.Html;
            cookie = result.Cookie;
            richTextBox1.Text = html;



        }


================================================

飞哥,别说发贴,顶贴都POST不到,,HELP
您需要登录后才可以回帖 登录 | 马上注册

本版积分规则

QQ|手机版|小黑屋|手机版|联系我们|关于我们|广告合作|苏飞论坛 ( 豫ICP备18043678号-2)

GMT+8, 2024-5-2 21:38

© 2014-2021

快速回复 返回顶部 返回列表