如何用httpWebRequest自动注册,并填写图片识别码

8620 2004-01-16 08:02:38
如何用httpWebRequest自动注册,并填写图片识别码
...全文
147 5 打赏 收藏 转发到动态 举报
写回复
用AI写文章
5 条回复
切换为时间正序
请发表友善的回复…
发表回复
designonline 2004-01-16
  • 打赏
  • 举报
回复
如果要登陆到ASP.NET写的程序,那怎么能登陆上去呢
孟子E章 2004-01-16
  • 打赏
  • 举报
回复
识别码图片要是能够轻易用程序识别,已经没有识别码的意义了,
gOODiDEA 2004-01-16
  • 打赏
  • 举报
回复
不太可能实现,数字验证的做法一般是把值保存在Session里,然后把图片识别码的值和该值比较,如果相等则验证成功。

2066 2004-01-16
  • 打赏
  • 举报
回复
一、图片识别码
Dim httpReq As System.Net.HttpWebRequest
Dim httpResp As System.Net.HttpWebResponse
Dim strBuff As String
Dim httpURL As New System.Uri("http://yourUrl.img.php?str=46203") '这是识别码图片的地址,你要换成你的地址
httpReq = CType(WebRequest.Create(httpURL), HttpWebRequest)
httpResp = CType(httpReq.GetResponse(), HttpWebResponse)
httpReq.KeepAlive = True        '保持链接,你就一直可以用这个识别码了
strBuff = "CharacterSet: " & httpResp.CharacterSet.ToString & ControlChars.CrLf
strBuff = strBuff & "ContentEncoding: " & httpResp.ContentEncoding.ToString & ControlChars.CrLf
strBuff = strBuff & "ContentLength: " & httpResp.ContentLength.ToString & ControlChars.CrLf
strBuff = strBuff & "ContentType: " & httpResp.ContentType.ToString & ControlChars.CrLf
strBuff = strBuff & "LastModified: " & httpResp.LastModified.ToString & ControlChars.CrLf
strBuff = strBuff & "Method: " & httpResp.Method.ToString & ControlChars.CrLf
strBuff = strBuff & "ProtocolVersion: " & httpResp.ProtocolVersion.ToString & ControlChars.CrLf
strBuff = strBuff & "ResponseUri: " & httpResp.ResponseUri.ToString & ControlChars.CrLf
strBuff = strBuff & "Server: " & httpResp.Server.ToString & ControlChars.CrLf
strBuff = strBuff & "StatusCode: " & httpResp.StatusCode.ToString & ControlChars.CrLf
strBuff = strBuff & "StatusDescription: " & httpResp.StatusDescription.ToString & ControlChars.CrLf
httpReq.Method = "GET"
MsgBox(strBuff)


二、自动注册
Dim httpUrl2 As New System.Uri("http://yourUrl/cgi-bbs/signup.cgi?" & "bookname=1®id=1&str=1&userid=459&password=1&confirm=1&username=1&cardnumber=1") '在地址后挂上你要注册的信息,什么用户名密码什么的
Dim req As HttpWebRequest
req.Timeout = 10000 '超时5秒
req = CType(WebRequest.Create(httpUrl2), HttpWebRequest)
req.Method = "POST"      
req.ContentType = "application/x-www-form-urlencoded"   ’这句一定要
Dim bytesData() As Byte = System.Text.Encoding.ASCII.GetBytes("bookname=1®id=1&str=1&userid=459&password=1&confirm=1&username=1&cardnumber=1")   ‘把注册信息转换在字节
req.ContentLength = bytesData.Length    ’注册信息的长度
Dim postStream As Stream = req.GetRequestStream()
postStream.Write(bytesData, 0, bytesData.Length)
postStream.Close()

Dim res As HttpWebResponse = CType(req.GetResponse(), HttpWebResponse)
MsgBox(res.StatusCode.ToString)
'Dim enc As Encoding = System.Text.Encoding.GetEncoding("GB2312")
'Dim sPostData As String = "content=" & HttpUtility.UrlEncode(sContent, enc) & "&name=" & HttpUtility.UrlEncode(sName, enc)  ‘如果有中文的内容,可能要用到这句


2066 2004-01-16
  • 打赏
  • 举报
回复
up

16,718

社区成员

发帖
与我相关
我的任务
社区描述
VB技术相关讨论,主要为经典vb,即VB6.0
社区管理员
  • VB.NET
  • 水哥阿乐
  • 无·法
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧