vb.net编写一个http form自动登录功能代码

代码语言:vb

所属分类:

代码描述:vb.net编写一个http form自动登录功能代码

代码标签: http form 自动 登录 功能

下面为部分代码预览,完整代码请点击下载或在bfwstudio webide中打开

Imports System
Imports System.IO
Imports System.Net
Imports System.Text
Namespace Examples.System.Net
    Public Class WebRequestPostExample
        Public Shared Sub Main()
            ' Create a request using a URL that can receive a post. 
            Dim request As WebRequest = WebRequest.Create("http://www.bfw.wiki/login.html")
            ' Set the Method property of the request to POST.
            request.Method = "POST"
            ' Create POST data and convert it to a byte array.
            Dim username, passwd As String
            username = "bfwuser" '账号
            passwd = "bfwpwd" '密码
           
            Dim postData As String = "username=" & username & "&passwd=" & passwd
            Dim byteArray As Byte() = Encoding.UTF8.GetBytes(postData)
            ' Set the ContentType property of the WebRequest.
            request.ContentType = "application/x-www-form-urlencoded"
            ' Set the ContentLength property of the WebRequest.
            request.ContentLength = byteArray.Length
            ' G.........完整代码请登录后点击上方下载按钮下载查看

网友评论0

相似代码