<HTML>
<head>
<title> Untitled Document</title >
(1)自动提交表单:
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
</head>
<script language=JavaScript>
    setTimeout( "document.form1.submit()", 10000)
</script>
<body bgcolor="#FFFFFF" text="#000000">
<form name="form1" method="post" action="pp.ASP">
 <p >
  <input type="text" name="textfield">
 </p >
 <p >
  <input type="text" name="textfield2">
 </p >
</form>
</body>
</html>
  
 
 
 
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.IO;
using System.Net;
using System.Web;
using System.Threading;
using System.Collections;
using System.Configuration;
using mshtml;
namespace WebRequestToLogin
{
    public partial class Default : Form
    {
        public Default()
        {
            InitializeComponent();
        }
        int i = 0;
 
        private void Form1_Load(object sender, EventArgs e)
        {
            //string ResultMsg = string.Empty;
            // Login("rivern@tom.com", "feiyang", "");
            //return;
           // webBrowser1.Navigate("http://qqapp.qq.com/app/" + this.textBoxPhone.Text.Trim() + ".html#jump=http%3a%2f%2frc.qzone.qq.com%2f100654250%3fvia%3dQZSTORE.XX.HOME-HOT.PAGE2.SEQ6_10008_200");
 
            this.textBoxPhone.Text = "100654070" ;
 
            button2_Click_1(sender,e);
       
        }
 
 
        private void Login(string UserName, string UserPwd, string LoginUrl)
        {
       
            // 
            // TODO: 在此处添加代码以启动应用程序 
            // 
            string url = "http://www.kaixin001.com/login/login.php" ;
            //            <% 
            //            if request("aa")="zhuye" then session("ok")="ok" 
            //            if session("ok")="ok" then 
            //            response.write("登录") 
            //            else 
            //            response.write("没有登录") 
            //            end if 
            //            %> 
            string indata = "url=/home/&invisible_mode=0&email=" + UserName + "&password=" + UserPwd;
            string outdata = "" ;
            CookieContainer myCookieContainer = new CookieContainer();
            //新建一个CookieContainer来存放Cookie集合 
            HttpWebRequest myHttpWebRequest = (HttpWebRequest )WebRequest.Create(url);
            //新建一个HttpWebRequest 
            myHttpWebRequest.ContentType = "application/x-www-form-urlencoded" ;
            myHttpWebRequest.ContentLength = indata.Length;
            myHttpWebRequest.Method = "POST";
            myHttpWebRequest.CookieContainer = myCookieContainer;
            //设置HttpWebRequest的CookieContainer为刚才建立的那个myCookieContainer 
            Stream myRequestStream = myHttpWebRequest.GetRequestStream();
            StreamWriter myStreamWriter = new StreamWriter(myRequestStream, Encoding.Default);
            myStreamWriter.Write(indata);
            //把数据写入HttpWebRequest的Request流 
            myStreamWriter.Close();
            myRequestStream.Close();
            //关闭打开对象 
            HttpWebResponse myHttpWebResponse = (HttpWebResponse)myHttpWebRequest.GetResponse();
            //新建一个HttpWebResponse 
            myHttpWebResponse.Cookies = myCookieContainer.GetCookies(myHttpWebRequest.RequestUri);
            //获取一个包含url的Cookie集合的CookieCollection 
            Stream myResponseStream = myHttpWebResponse.GetResponseStream();
            StreamReader myStreamReader = new StreamReader(myResponseStream, Encoding.UTF8);
            outdata = myStreamReader.ReadToEnd();
            //把数据从HttpWebResponse的Response流中读出 
            myStreamReader.Close();
            myResponseStream.Close();
            Console.WriteLine(outdata);
            //显示"登录" 
 
            //拿到了Cookie,再进行请求就能直接读取到登录后的内容了 
            myHttpWebRequest = ( HttpWebRequest)WebRequest .Create(url);
            myHttpWebRequest.CookieContainer = myCookieContainer; //* 
            //刚才那个CookieContainer已经存有了Cookie,把它附加到HttpWebRequest中则能直接通过验证 
            myHttpWebResponse = ( HttpWebResponse)myHttpWebRequest.GetResponse();
            myHttpWebResponse.Cookies = myCookieContainer.GetCookies(myHttpWebRequest.RequestUri);
            myResponseStream = myHttpWebResponse.GetResponseStream();
            myStreamReader = new StreamReader (myResponseStream, Encoding.UTF8);
            outdata = myStreamReader.ReadToEnd();
            myStreamReader.Close();
            myResponseStream.Close();
            Console.WriteLine(outdata);
            //再次显示"登录" 
            //如果把*行注释调,就显示"没有登录" 
  
        }
       
            private void Button2_Click(object sender, EventArgs e)
            {
              
                    try
                    {
                        string strhtml = string .Empty;
 
            
                        this.timerHLSet.Start();
                       // this.timerRef.Start();
                        MessageBox.Show("启动任务成功!" );
                    }
                    catch (Exception ex)
                    {
                        //
                    }
            }
 
        private void HtmlMsc()
        {
            try
            {
 
                webBrowser1.Navigate( "http://qqapp.qq.com/app/" + this .textBoxPhone.Text.Trim() + ".html#jump=http%3a%2f%2frc.qzone.qq.com%2f100654250%3fvia%3dQZSTORE.XX.HOME-HOT.PAGE2.SEQ6_10008_200" );
                System.Windows.Forms. HtmlDocument document = this .webBrowser1.Document;
              
                if (document == null )
                {
                    return;
                }
                //document.All["mobile1"].SetAttribute("value", this.textBoxPhone.Text.Trim());            //用户名  
              
 
                //根据ID来自动点击CLICK
                webBrowser1.Document.GetElementById( "gotoapp-link").InvokeMember("click" );//当按钮是authZForm.submit()
 
                //根据标莶来点击
                //HtmlElementCollection Html = webBrowser1.Document.GetElementsByTagName("img");
                //foreach (HtmlElement h in Html)
                //{
                //    h.InvokeMember("click");
                //    this.webBrowser1.ScriptErrorsSuppressed = true;
                //    this.webBrowser1.Refresh();
                //}
                webBrowser1.Stop();
                this.labelNo.Text = "任务被执行" + i + "次";
                i++;
            }
            catch (Exception ex)
            { }
        }
 
            private void notifyIcons_Click(object sender, EventArgs e)
            {
                this.Visible = true ;
 
                this.WindowState = FormWindowState .Normal;
 
                this.notifyIcons.Visible = false ;
 
            }
 
            private void Form1_SizeChanged(object sender, EventArgs e)
            {
                if (this .WindowState == FormWindowState.Minimized)
                {
                    this.Hide();
                    this.notifyIcons.Visible = true ;
                }
            }
 
            private void timerHLSet_Tick(object sender, EventArgs e)
            {
                HtmlMsc();
            }
 
            private void timerRef_Tick(object sender, EventArgs e)
            {
                try
                {
                 
                    webBrowser1.Navigate( "http://m.tom.cn/appweb/163/download.jsp?id=1" );
                    this.webBrowser1.ScriptErrorsSuppressed = true ;
                    this.webBrowser1.Refresh();
                }
                catch (Exception ex)
                {
 
                }
            }
 
            private void webBrowser1_Navigated(object sender, WebBrowserNavigatedEventArgs e)
            {
                IHTMLWindow2 win = (IHTMLWindow2)webBrowser1.Document.Window.DomWindow;
                string s = "window.alert = null;\r\nwindow.confirm = null;\r\nwindow.open = null;\r\nwindow.showModalDialog = null;";
                win.execScript(s, "javascript");
 
 
 
            }
 
            private void webBrowser1_NewWindow(object sender, CancelEventArgs e)
            {
                e.Cancel = true;
 
        
 
            }
 
            private void timerr_Tick(object sender, EventArgs e)
            {
                string strurl = null ;
                strurl = webBrowser1.Url.AbsoluteUri;
                string[] str = strurl.Split('=' );
 
                foreach (string s in str)
                {
                    if (s == "http://www.qq.com/?oauth_token" )
                        this.timerr.Stop();
                    break;
                }
                string strurlx = str[1].ToString();
                string[] strx = strurlx.Split('&' );
 
                MessageBox.Show(strx[0].ToString());
                MessageBox.Show(str[2].ToString());
            }
 
            private void button1_Click(object sender, EventArgs e)
            {
                try
                {
 
                    webBrowser1.Navigate("http://qqapp.qq.com/app/" +this.textBoxPhone.Text.Trim()+ ".html#jump=http%3a%2f%2frc.qzone.qq.com%2f100654250%3fvia%3dQZSTORE.XX.HOME-HOT.PAGE2.SEQ6_10008_200" );
                   
                    System.Windows.Forms. HtmlDocument document = this .webBrowser1.Document;
 
                    if (document == null )
                    {
                        return;
                    }
               
                    //document.All["mobile1"].SetAttribute("value", this.textBoxPhone.Text.Trim());            //用户名  
 
                    webBrowser1.Document.GetElementById("gotoapp-link" ).InvokeMember("click"); //当按钮是authZForm.submit()
                    webBrowser1.Stop();
                }
                catch (Exception ex)
                {
                    //if (!string.IsNullOrEmpty(ex.Message))
                    //    button1_Click(sender,e);
                }
 
              
            }
 
            private void herfclick(string url)
            {
                for (int i = 0; i < webBrowser1.Document.All.Count; i++)
                {
                    if (webBrowser1.Document.All[i].TagName == "A" && webBrowser1.Document.All[i].GetAttribute("href" ).ToString().Trim() == url)
                    {
                        webBrowser1.Document.All[i].InvokeMember( "click");//引发”CLICK”事件
                        break;
                    }
                }
            }
 
            private void button2_Click_1(object sender, EventArgs e)
            {
                webBrowser1.Navigate("http://ptlogin2.qq.com/jump?clientuin=309159808&clientkey=000151a4219f006858f02f51c30196d0c6e7f2518b441bf6d88812a22b4b11690f21a5c12a54bdd388d618793860942665ee01d80eb22358577984a0105b7a771b9376dc380681931f39749b0c619eb534f3dd70e3b7ac4890d6b22cc084b86fa51d881759375642fcb4b2894d002075&keyindex=9&pt_aid=549000912&u1=http%3A%2F%2Fqzs.qq.com%2Fqzone%2Fv5%2Floginsucc.html%3Fpara%3Dizone" );
               
            }
    }
}
  

打开页面时就提交,可以做一些自动登陆 还有SICLOGIN的测试代码的更多相关文章

  1. 判断手机端用户打开页面时是android还是ios,并将判断结果通过ajax返回给url接口,传递回去

    首先判断页面是android还是ios,然后利用ajax将结果通过接口url返回回去,记录到log日志中,以统计android和ios用户访问该页面的数量(数据统计) <script type= ...

  2. 获取打开页面时的当前时间(yyyy-MM-dd hh:mm:ss)

    Date.prototype.Format = function (fmt) { var o = { "M+": this.getMonth() + 1, //月份 "d ...

  3. 打开powerDesigner时,创建table对应的自动生成sql语句没有注释

    在创建pdm时由于需要在name列填写的是以后要在表中创建的注释信息,comment中则写的说明信息字数比较多.默认情况下在生成建表sql时不能将name生成注释信息,进行如下设置可以讲name生成注 ...

  4. 【转】iframe和父页,window.open打开页面之间的引用

    [转]iframe和父页,window.open打开页面之间的引用 iframe和父页,window.open打开页面和被打开页面之间的关系可以通过下面的对象获取到 1)通过iframe加载的,在if ...

  5. 怎么隐藏 iOS Safari 打开网页时的地址栏和工具栏探索

    先来看一张截图 红色框处就是用手机浏览器打开页面时,自动显示出来的头部地址栏和底部工具栏 如果现在有一个需求,用手机浏览器打开页面时,把地址栏和工具栏隐藏,该怎么办呢? 起初我在度娘找到了好几篇博客都 ...

  6. 【模态窗口-Modeldialog】提交请求时禁止在新窗口打开页面的处理方法

    在使用Window.ShowModalDialog()打开模态窗口后,在模态窗口内提交时总是会在新窗口中打开. 解决办法: 在要弹出的窗口的<head>之间加: <base targ ...

  7. 前端动态属性页面的 要用id做name 因为这样方便在提交表单时候取到值

    前端动态属性页面的 要用id做name 因为这样方便在提交表单时候取到值

  8. jquery模拟form表单提交并新打开页面

    /** * form表单提交本页面打开 * @param url * @param params */ function postCurrent(url,params){ var form = $(& ...

  9. 打开jsp页面时,显示空白页。

    打开jsp页面时,显示空白页.   #foreach($e in $listPlanItem)          #set($listPlanDetail=$!e.get(2))        < ...

随机推荐

  1. 在TFS中获取项目,获取最新和上传(迁入)

    一.在TFS中获取项目: (1)team (2)connect to team.... (3)选择服务地址,然后close (4)然后映射本地文件夹下载项目 (5)mapped添加映射,在map下就可 ...

  2. Codeforces 1120C Compress String(DP)

    题意:给你一个字符串,有2种消除方式:1:消除一个单独的字母,代价为a.2:s[j]到s[k]是s[1]到s[j - 1]的子串,那么s[j]到s[k]可以消除,代价为b,问最小的代价. 思路:官方题 ...

  3. 关闭是否只查看安全传送的网页内容提示框 和 是否允许运行软件,如ActiveX控件和插件提示框

    关闭是否只查看安全传送的网页内容提示框 最新编写 爬虫程序,运行程序后,电脑就总是出现下面这个提示框,一遍遍点"是"或"否"繁琐又麻烦.我看得有点不耐烦了.于是 ...

  4. SqlDataAdapter 批量更新数据库表

    在数据库中批量插入数据许多人都已经了解了,就是使用.net 中的SqlBulkCopy对象(MSDN详解).我们在做评教系统的时候使用过这个对象,它能将数据表批量导入到数据库中,效率比单条插入数据效率 ...

  5. 2012年长春网络赛(hdu命题)

    为迎接9月14号hdu命题的长春网络赛 ACM弱校的弱菜,苦逼的在机房(感谢有你)呻吟几声: 1.对于本次网络赛,本校一共6名正式队员,训练靠的是完全的自主学习意识 2.对于网络赛的群殴模式,想竞争现 ...

  6. SQL语句学习积累·数据的操作

    数据的操作 select 取表中前五条数据 select top 5 from table_name 取表中前50%的数据 select top 50 percent from table_name ...

  7. php无限级分类

    使用递归方法,遍历子类,对数据进行重新排序,使用level进行无限级分类 /** * 功能:无限级分类 * 参数:$data 类别查询结果集 * 返回值:$arr 排序后的数组 */ public f ...

  8. css总结16:HTML5 多媒体音频(Audio)视频(video )

    1 显示嵌入网页中的 MP3 文件: <embed height="50" width="100" src="horse.mp3"&g ...

  9. 注入学习1:SQL注入语句大全

    学习背景 之前做了xss预防,以及些许的注入预防了,但是不够全面,如果还是搜集了下一些常用的注入手段,以此用来进行更好的预防. 什么是注入 一般来说,SQL注入一般存在于形如:HTTP://xxx.x ...

  10. 新的云主机 python 创建虚拟环境

    1.为什么要搭建虚拟环境? 问题:如果在一台电脑上, 想开发多个不同的项目, 需要用到同一个包的不同版本, 如果使用上面的命令, 在同一个目录下安装或者更新, 新版本会覆盖以前的版本, 其它的项目就无 ...