惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

S
Secure Thoughts
罗磊的独立博客
T
The Blog of Author Tim Ferriss
人人都是产品经理
人人都是产品经理
博客园 - 叶小钗
Last Week in AI
Last Week in AI
美团技术团队
Google Online Security Blog
Google Online Security Blog
Application and Cybersecurity Blog
Application and Cybersecurity Blog
D
Docker
G
Google Developers Blog
大猫的无限游戏
大猫的无限游戏
酷 壳 – CoolShell
酷 壳 – CoolShell
小众软件
小众软件
月光博客
月光博客
L
LINUX DO - 最新话题
cs.AI updates on arXiv.org
cs.AI updates on arXiv.org
CTFtime.org: upcoming CTF events
CTFtime.org: upcoming CTF events
W
WeLiveSecurity
H
Heimdal Security Blog
Vercel News
Vercel News
SecWiki News
SecWiki News
Forbes - Security
Forbes - Security
Blog — PlanetScale
Blog — PlanetScale
Google DeepMind News
Google DeepMind News
Exploit-DB.com RSS Feed
Exploit-DB.com RSS Feed
www.infosecurity-magazine.com
www.infosecurity-magazine.com
TaoSecurity Blog
TaoSecurity Blog
T
Troy Hunt's Blog
A
About on SuperTechFans
C
Check Point Blog
S
Security Affairs
Hacker News - Newest:
Hacker News - Newest: "LLM"
AI
AI
WordPress大学
WordPress大学
K
KPMG report finds enterprise disconnect between AI and its ROI | CIO
Help Net Security
Help Net Security
博客园_首页
The Last Watchdog
The Last Watchdog
S
SegmentFault 最新的问题
Hugging Face - Blog
Hugging Face - Blog
Security Archives - TechRepublic
Security Archives - TechRepublic
Engineering at Meta
Engineering at Meta
cs.CV updates on arXiv.org
cs.CV updates on arXiv.org
I
Intezer
K
Kaspersky official blog
M
MIT News - Artificial intelligence
J
Java Code Geeks
G
GRAHAM CLULEY
P
Palo Alto Networks Blog

博客园 - 白天的萤火虫

Net开源框架/项目,你研究过几个? 主题:实用且不花哨的js代码大全 字字带泪-写在三十岁到来这一天 关于silverlight的安装 推荐一个IE下的优秀js调试工具(Companion.JS) 给分页控件增加一列 编号 关于Ajax的web配置 - 白天的萤火虫 - 博客园 一个行转列的例子 获取HTML代码 - 白天的萤火虫 - 博客园 最新Silverlight开发环境配置介绍 sql server中的存储过程调试 PetShop介绍集锦 DIV+CSS实现圆角 button 绑定 enter键 转载---使用Ajax实现DropDownList和ListBox的联动以及两个ListBox之间数据的移动 自己调试通过的存储过程 又一个通用分页存储过程,支持表别名,多表联合查询SQL语句--转载 写入和读取cookie CascadingDropDown从数据库中读取数据绑定到DropDownList控件上
关于模拟注册登录的
白天的萤火虫 · 2009-04-23 · via 博客园 - 白天的萤火虫
【Red_angelX】:
没图片验证,即使有,各个网站也不一样 很难做到通用

【Red_angelX】:
自己看HttpWebRequest就可以了

【lovepp2004】:
呵呵。无图片验证无所谓。我想看看怎么实现。呵呵

【tl_pear】:
学习

【zhangliu_521】:
Red_angelX(八戒) 说得对.
各个网站也不一样 很难做到通用

看HttpWebRequest
POST数据

用单独的网站做练习.先搞定一个再说

【mudong303】:
这个东西我做过 就是 HttpWebRequest 很简单 就是设置下head 用post到指定地址就可以啦
不过cookie是个难点,取得图片和取得首页 到登陆完成 cookie要维持,还有不同的网站,登陆前后获取cookie和cookie个数都有所不同

【lovepp2004】:
呵呵。有代码的发奥。我也先去看看httpwebrequest了。哈哈

【zhangliu_521】:
tring url = "http://my.b2b.hc360.com/my/turbine/template/firstview,other_login.html";

string indata = @"LoginID=mytestcs&Passwd=aabbccdd&LoginChk=true&Submit=%B5%C7%A1%A1%A1%A1%C2%BC";

            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.GetEncoding("gb2312"));                 
            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.GetEncoding("gb2312")); 
            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.GetEncoding("gb2312")); 
            outdata=myStreamReader.ReadToEnd(); 
            myStreamReader.Close(); 
            myResponseStream.Close(); 
            Console.WriteLine(outdata);

【zhangliu_521】:
如何给网页Post数据
///////////////////////////////////////////////////////////////////////////   
  //SDK   post   
  ///////////////////////////////////////////////////////////////////////////   
  #include   "stdafx.h"   
  #include   "winsock.h"   
  #pragma   comment(lib,"ws2_32.lib")   
  #define   winsock_version   0x0101   
  void   main()   
  {   
  //I   create     C:\Inetpub\wwwroot\test\test.asp   ,start   the   web   service   
  //start   my   program,   the   result   is   OK.   
  //If   it   works,it   is   written   by   masterz,otherwise   I   don't   know   who   write   it.   
          SOCKADDR_IN   saServer;   
  LPHOSTENT   lphostent;   
  WSADATA   wsadata;   
          SOCKET   hsocket;   
  int   nRet;   
  const   char*   host_name="127.0.0.1";   
  char*   req="POST   /test/test.asp   HTTP/1.0\r\n"   
  "From:   local\r\n"   
  "User-Agent:   post_test/1.0\r\n"   
  "Content-Type:   application/x-www-form-urlencoded\r\n"   
  "Content-Length:   20\r\n\r\n"   
  "type=12345&name=aaaa";   
  if(WSAStartup(winsock_version,&wsadata))   
  printf("can't   initial   socket");   
          lphostent=gethostbyname(host_name);   
          if(lphostent==NULL)   
  printf("lphostent   is   null");   
  hsocket   =   socket(AF_INET,   SOCK_STREAM,   IPPROTO_TCP);   
          saServer.sin_family   =   AF_INET;   
  //   Use   def.   now,   need   to   handle   general   case   
  saServer.sin_port   =   htons(80);   
  saServer.sin_addr   =   *((LPIN_ADDR)*lphostent->h_addr_list);   
          nRet   =   connect(hsocket,   (LPSOCKADDR)&saServer,   sizeof(SOCKADDR_IN));   
  if   (nRet   ==   SOCKET_ERROR)   
  {   
  printf("can't   connect");   
  closesocket(hsocket);   
  return;   
  }   
  else   
  printf("connected   with   %s\n",host_name);   
  nRet   =   send(hsocket,   req,   strlen(req),   0);   
  if   (nRet   ==   SOCKET_ERROR)   
  {   
  printf("send()   failed");   
  closesocket(hsocket);   
    
  }   
  else   
  printf("send()   OK\n");   
  char   dest[1000];   
  nRet=1;   
  while(nRet>0)   
  {   
  nRet=recv(hsocket,(LPSTR)dest,sizeof(dest),0);   
  if(nRet>0)   
  dest[nRet]=0;   
  else   
  dest[0]=0;   
  printf("\nReceived   bytes:%d\n",nRet);   
  printf("Result:\n%s",dest);   
  }   
  }

void   post()   
  {   
          CInternetSession   session("My   Session");   
          CHttpConnection*   pServer   =   NULL;   
          CHttpFile*   pFile   =   NULL;   
          CString   ServerName   =   "webmail.21cn.com";   
          INTERNET_PORT   nPort   =   80;   
          DWORD   retcode;   
          char   outBuff[300]   =   "LoginName=aaa&passwd=xxx&DomainName=21cn.com";//I   have   test   this   with   my   loginname   and   password   
          try   
          {   
                  pServer   =   session.GetHttpConnection(ServerName,nPort);   
                  pFile   =   pServer->OpenRequest(CHttpConnection::HTTP_VERB_POST,"/NULL/NULL/NULL/NULL/NULL/SignIn.gen",NULL,1,NULL,NULL,INTERNET_FLAG_EXISTING_CONNECT);   
                  pFile   ->   AddRequestHeaders("Content-Type:   application/x-www-form-urlencoded");   
                  pFile   ->   AddRequestHeaders("Accept:   */*");   
                  pFile   ->   SendRequest(NULL,0,outBuff,strlen(outBuff)+1);   
                  pFile   ->   QueryInfoStatusCode(retcode);   
                  //   you   can   read   from   the   file   after   this......I've   just   left   it   out.   
                  for(int   i=0;i<10;i++)//read   ten   line   of   returned   HTML,you   need   to   edit   this   to   use   the   result   
                  {   
                  CString   smsg;   
                  pFile->ReadString(smsg);   
                  AfxMessageBox(smsg);   
                  }   
  DWORD   dwlen=pFile->GetLength();   
  char   buf[1024];   
  DWORD   dwread=pFile->Read(buf,1024);   
          }   
          catch   (CInternetException   *   e){};   
          delete   pFile;   
          delete   pServer;   
          session.Close();   
  }

【zhangliu_521】:

 
这个是提交的数据类:
 using System.Collections;
 using System.IO;
 
 public class RequestData
  {
 ArrayList arr=new ArrayList();
 public RequestData()
  {
 
 }
 
 public string GetData()
  {
 string r="";
 
 for(int i=0;i<arr.Count;i++)
  {
 data d=(data)arr[i];
 if(r.Length>0)r+="&";
 r+=d.Field+"="+d.Value;
 }
 return r;
 }
 
 public void AddField(string Field,string Value)
  {
 data a=new data();
 a.Field=Field;
 a.Value=Value;
 
 arr.Add(a);
 }
 
 struct data
  {
 public string Field,Value;
 }
 
 
 }

可以参考

【seemon】:
呵呵,都不用c#,直接用javascript就可以了
自己做一个form把要填的内容在form里初始化好,把action设置成目标地址,不停的submit就可以了

【Red_angelX】:
private string GetUrlContext(string curl)
{
    string text = "";
    if (this.method == 1) //Get
    {
        HttpWebRequest request = (HttpWebRequest) WebRequest.Create(new Uri(curl));
        ServicePointManager.Expect100Continue = false;
        HttpWebResponse response = null;
        if (Form1.C_IsProxyOn)
        {
            WebProxy proxy = new WebProxy();
            proxy = (WebProxy) request.Proxy;
            string uriString = Form1.C_Proxy_addr + ":" + Form1.C_Proxy_port;
            if (uriString.Length > 0)
            {
                Uri uri = new Uri(uriString);
                proxy.Address = uri;
                proxy.Credentials = new NetworkCredential(Form1.C_Proxy_user, Form1.C_Proxy_pass);
                request.Proxy = proxy;
            }
        }
        try
        {
            response = (HttpWebResponse) request.GetResponse();
        }
        catch (WebException exception)
        {
            if (exception.Status == WebExceptionStatus.ProtocolError)
            {
                response = (HttpWebResponse) exception.Response;
            }
            else if (exception.Status == WebExceptionStatus.ConnectFailure)
            {
                MessageBox.Show("\u8fde\u63a5\u670d\u52a1\u5668\u5931\u8d25,\u8bf7\u68c0\u67e5\u7f51\u7edc", "\u9519\u8bef");
            }
            else
            {
                MessageBox.Show(exception.ToString());
            }
        }
        Stream responseStream = response.GetResponseStream();
        StreamReader reader = new StreamReader(responseStream, Encoding.Default);
        text = reader.ReadToEnd();
        responseStream.Close();
        response.Close();
        reader.Close();
        return text;
    }
//Post
    string[] textArray = new string[2];
    textArray = curl.Split(new char[] { '?' });
    HttpWebRequest request2 = (HttpWebRequest) WebRequest.Create(new Uri(textArray[0]));
    ServicePointManager.Expect100Continue = false;
    request2.Method = "POST";
    CookieContainer container = new CookieContainer();
    request2.CookieContainer = container;
    string s = textArray[1];
    byte[] bytes = new ASCIIEncoding().GetBytes(s);
    request2.ContentType = "application/x-www-form-urlencoded";
    request2.ContentLength = s.Length;
    Stream requestStream = request2.GetRequestStream();
    requestStream.Write(bytes, 0, bytes.Length);
    requestStream.Close();
    if (Form1.C_IsProxyOn)
    {
        WebProxy proxy = new WebProxy();
        proxy = (WebProxy) request2.Proxy;
        string uriString = Form1.C_Proxy_addr + ":" + Form1.C_Proxy_port;
        if (uriString.Length > 0)
        {
            Uri uri2 = new Uri(uriString);
            proxy.Address = uri2;
            proxy.Credentials = new NetworkCredential(Form1.C_Proxy_user, Form1.C_Proxy_pass);
            request2.Proxy = proxy;
        }
    }
    HttpWebResponse response = null;
    try
    {
        response = (HttpWebResponse) request2.GetResponse();
    }
    catch (WebException exception2)
    {
        if (exception2.Status == WebExceptionStatus.ProtocolError)
        {
            response = (HttpWebResponse) exception2.Response;
        }
        else if (exception2.Status == WebExceptionStatus.ConnectFailure)
        {
            MessageBox.Show("\u8fde\u63a5\u670d\u52a1\u5668\u5931\u8d25,\u8bf7\u68c0\u67e5\u7f51\u7edc", "\u9519\u8bef");
        }
        else
        {
            MessageBox.Show(exception2.ToString());
        }
    }
    response.Cookies = request2.CookieContainer.GetCookies(request2.RequestUri);
    Stream stream = response.GetResponseStream();
    StreamReader reader2 = new StreamReader(stream, Encoding.Default);
    text = reader2.ReadToEnd();
    stream.Close();
    response.Close();
    reader2.Close();
    return text;
}

【lovepp2004】:
谢谢大家了。今天学习了不少。呵呵。散分~

【superliyubo】:
mark~~~~

【Fooo】:
mark~~~~