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

苏飞论坛

 找回密码
 马上注册

QQ登录

只需一步,快速开始

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

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

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

查看: 7499|回复: 2

[例子] phpwind8.7 POST登陆DEMO

[复制链接]
发表于 2015-8-19 11:55:56 | 显示全部楼层 |阅读模式
本帖最后由 79079748 于 2015-8-19 11:58 编辑

rt:
用万能框架做的...

QQ截圖20150819115506.jpg

--------------------------------------------------------------------------------
上代码:
[C#] 纯文本查看 复制代码
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Web;
using CsharpHttpHelper;
using CsharpHttpHelper.Enum;
using System.Text.RegularExpressions;
using System.Threading;
using System.Net;
using System.Runtime.InteropServices;


namespace phpwindPost
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }
      
      
        private void button1_Click(object sender, EventArgs e)
        {
            string url = textBox1.Text.Trim();
            string u1 = url.Replace("http://","").Replace("/login.php","");
            
            HttpHelper http = new HttpHelper();
             HttpItem item = new HttpItem()
             {
                 URL = url,
                 Method = "get",
           
                 ContentType = "application/x-www-form-urlencoded",
                 UserAgent = "Mozilla/5.0 (compatible; MSIE 9.0; Windows NT 6.1; Trident/5.0)",
               
                 Allowautoredirect = true,
                ResultCookieType = ResultCookieType.CookieCollection
                  //Cookie=result.Cookie
                

             };
             HttpResult result = http.GetHtml(item);
             string html = result.Html;
            string hash= HttpHelper.GetBetweenHtml(html,"name=\"verify\" value=\"","\" />");
            string cook = HttpHelper.GetBetweenHtml(result.Cookie, "PHPSESSID=",";");
            textBox4.AppendText("未登陆的verity:" + hash + "\r\n" + "未登陆的PHPSESSID:" + cook + "\r\n");
            
            // textBox4.Text = result.Html;
         
                item = new HttpItem()
                {
                    URL = url,
                    Method = "POST",
                    
                    Postdata = "verify=" + hash + "&forward=&jumpurl=http%3A%2F%2F" + u1 + "%2Findex.php&step=2&lgt=0&pwuser=" + textBox2.Text.Trim() + "&pwpwd=" + textBox3.Text.Trim() + "&hideid=0&submit=",
                    ContentType = "application/x-www-form-urlencoded",
                    UserAgent = "Mozilla/5.0 (compatible; MSIE 9.0; Windows NT 6.1; Trident/5.0)",
                    
                    Cookie = "36f7f_cloudClientUid=50519953; 36f7f_wap_scr=a%3A1%3A%7Bs%3A4%3A%22page%22%3Bs%3A5%3A%22index%22%3B%7D; 36f7f_cloudcksessionid=d0f121fdbbd36846dcd75b621a05ed1b; 36f7f_threadlog=%2C10%2C; 36f7f_clearm_20485=2; PHPSESSID=" + cook + "; 36f7f_clearm_9806=7; 36f7f_readlog=%2C518299%2C530427%2C; td_cookie=118221962; 36f7f_jobpop=0; 36f7f_ol_offset=103790; 36f7f_lastpos=other; 36f7f_lastvisit=5%091439951805%09%2Flogin.php; CNZZDATA431337=cnzz_eid%3D1417483821-1439459127-http%253A%252F%252F" + u1 + "%252F%26ntime%3D1439947603"

                };
             
                result = http.GetHtml(item);
                html = result.Html;
                string winduser = HttpHelper.GetBetweenHtml(result.Cookie, "winduser=", ";");
                textBox4.AppendText(HttpHelper.GetBetweenHtml(html, "<p class=\"f14 mb10\">", "</p>") + "\r\n" + "登陆后ID:" + winduser + "\r\n");
            
     
              
             item = new HttpItem()
               {
               
                   URL = "http://"+u1+"/u.php",
                  Method = "get",
                   ContentType = "application/x-www-form-urlencoded",
                   UserAgent = "Mozilla/5.0 (compatible; MSIE 9.0; Windows NT 6.1; Trident/5.0)",
                 
                   Allowautoredirect = true,
                   Cookie = "36f7f_cloudClientUid=50519953; 36f7f_wap_scr=a%3A1%3A%7Bs%3A4%3A%22page%22%3Bs%3A5%3A%22index%22%3B%7D; 36f7f_readlog=%2C518299%2C; 36f7f_cloudcksessionid=d0f121fdbbd36846dcd75b621a05ed1b; 36f7f_threadlog=%2C10%2C; 36f7f_clearm_20485=2; PHPSESSID="+cook+"; 36f7f_clearm_9806=7; 36f7f_jobpop=0; 36f7f_winduser="+winduser+"; 36f7f_ck_info=%2F%09; 36f7f_ol_offset=16587; 36f7f_lastpos=other; td_cookie=117834890; 36f7f_lastvisit=3000%091439947928%09%2Fu.php; CNZZDATA431337=cnzz_eid%3D1417483821-1439459127-http%253A%252F%252F"+u1+"%252F%26ntime%3D1439944040"
                 
                
               };
               result = http.GetHtml(item);
               string title = HttpHelper.GetHtmlTitle(result.Html);
               string verity = HttpHelper.GetBetweenHtml(result.Html, "verifyhash = '", "';");
               textBox4.AppendText("登陆后的用户名:" + HttpHelper.GetHtmlTitle(result.Html) + "\r\n" + "登陆后的verity:" + verity);
              item = new HttpItem()
               {
                   URL = "http://"+u1+"/pw_ajax.php?action=addattention&touid=" + 2 + "&nowtime=1439863790953&verify=" + verity,
                   Method = "get",
                   ContentType = "application/x-www-form-urlencoded",
                   UserAgent = "Mozilla/5.0 (compatible; MSIE 9.0; Windows NT 6.1; Trident/5.0)",

                   Allowautoredirect = true,
                   Cookie = "36f7f_cloudClientUid=50519953; 36f7f_wap_scr=a%3A1%3A%7Bs%3A4%3A%22page%22%3Bs%3A5%3A%22index%22%3B%7D; 36f7f_readlog=%2C518299%2C; 36f7f_cloudcksessionid=d0f121fdbbd36846dcd75b621a05ed1b; 36f7f_threadlog=%2C10%2C; 36f7f_clearm_20485=2; PHPSESSID="+cook+"; 36f7f_clearm_9806=7; 36f7f_jobpop=0; 36f7f_winduser="+winduser+"; 36f7f_ck_info=%2F%09; 36f7f_ol_offset=16587; 36f7f_lastpos=other; td_cookie=117769421; 36f7f_lastvisit=2353%091439947281%09%2Fu.php%3Fuid142146; CNZZDATA431337=cnzz_eid%3D1417483821-1439459127-http%253A%252F%252F"+u1+"%252F%26ntime%3D1439942182"
               };
              result = http.GetHtml(item);
              textBox4.AppendText("\r\n" + HttpHelper.GetBetweenHtml(result.Html, "<ajax>", "</ajax>"));
              item = new HttpItem()
              {
                  URL = "http://"+u1+"/u.php?uid=2",
                  Method = "get",
                  ContentType = "application/x-www-form-urlencoded",
                  UserAgent = "Mozilla/5.0 (compatible; MSIE 9.0; Windows NT 6.1; Trident/5.0)",

                  Allowautoredirect = true,
               
              };
              result = http.GetHtml(item);
              textBox4.AppendText("用户名:" + HttpHelper.GetBetweenHtml(result.Html, "h2 id=\"spaceName\">", "的个人主页"));
              
       }
     
    }
}




1. 开通SVIP会员,免费下载本站所有源码,不限次数据,不限时间
2. 加官方QQ群,加官方微信群获取更多资源和帮助
3. 找站长苏飞做网站、商城、CRM、小程序、App、爬虫相关、项目外包等点这里
发表于 2015-8-19 14:05:14 | 显示全部楼层
看过帖子回复一下是个好习惯
发表于 2015-8-19 14:31:31 | 显示全部楼层
我只是路过打酱油的。
您需要登录后才可以回帖 登录 | 马上注册

本版积分规则

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

GMT+8, 2024-11-15 12:20

© 2014-2021

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