关于vb.net中http的信息
VB.NET HttpWebRequest根据MSDN写法获取不到COOKIE,有的可以但不完整
嘿嘿,试试下面这个api
十余年的讷河网站建设经验,针对设计、前端、开发、售后、文案、推广等六对一服务,响应快,48小时及时工作处理。成都全网营销推广的优势是能够根据用户设备显示端的尺寸不同,自动调整讷河建站的显示方式,使网站能够适用不同显示终端,在浏览器中调整网站的宽度,无论在任何一种浏览器上浏览网站,都能展现优雅布局与设计,从而大程度地提升浏览体验。创新互联建站从事“讷河网站设计”,“讷河网站推广”以来,每个客户项目都认真落实执行。
Private Const INTERNET_COOKIE_HTTPONLY As Integer = H2000
SuppressUnmanagedCodeSecurity, SecurityCritical, DllImport("wininet.dll", EntryPoint:="InternetGetCookieExW", SetLastError:=True, ExactSpelling:=True)
Friend Function InternetGetCookieEx([In] Url As String, [In] cookieName As String, Out cookieData As StringBuilder, [In], Out ByRef pchCookieData As UInteger, flags As UInteger, reserved As IntPtr) As Boolean
End Function
''' summary
''' 获取webbrowser登录成功后的cookie,需要带上登录成功后的URL
''' /summary
''' param name="url"/param
''' returns/returns
SecurityCritical()
Public Function GetCookie(url As String) As String
Dim size As UInteger = 0
Dim sb As New StringBuilder
If InternetGetCookieEx(url, vbNullString, Nothing, size, INTERNET_COOKIE_HTTPONLY, IntPtr.Zero) Then '-- this always returns false
If size = 0 Then
Return Nothing
End If
sb = New StringBuilder(Convert.ToInt32(size) + 1)
If Not InternetGetCookieEx(url, vbNullString, sb, size, INTERNET_COOKIE_HTTPONLY, IntPtr.Zero) Then
Return Nothing
End If
End If
Dim lastErrorCode = Marshal.GetLastWin32Error '-- 259
Return sb.ToString()
End Function
另外,再给你一个函数
''' summary
''' 字符串型的cookie转换成cookie型的cookiecollection
''' /summary
''' param name="cookieStr"/param
''' param name="cookie"/param
''' param name="domain"/param
Public Sub StringToCookie(ByVal cookieStr As String, ByRef cookie As CookieContainer, ByVal domain As String)
cookie = New CookieContainer()
Debug.Print($"过程:{New StackTrace().GetFrame(0).GetMethod.Name} 转换cookie开始")
Try
Dim cookstr As String() = cookieStr.Split(";"c)
Dim cookieName As String = ""
Dim cookieValue As String = ""
For Each str As String In cookstr
cookieName = str.Substring(0, InStr(str, "=") - 1).Trim()
cookieValue = str.Substring(InStr(str, "="), str.Length - InStr(str, "=")).Trim()
Dim ck As New Cookie(cookieName, cookieValue)
'Debug.Print($"{cookieName} = {cookieValue}")
ck.Domain = domain
cookie.Add(ck)
Next
Debug.Print($"过程:{New StackTrace().GetFrame(0).GetMethod.Name} 转换cookie成功")
Catch ex As Exception
Debug.Print($"过程:{New StackTrace().GetFrame(0).GetMethod.Name} {ex.StackTrace.ToString()}")
Finally
Debug.Print($"过程:{New StackTrace().GetFrame(0).GetMethod.Name} 转换cookie结束")
End Try
End Sub
用VB.NET 怎样通过给的HTTP地址上传文件
e As Int32 = 0 To Files.Count - 1
Dim PostedFile As HttpPostedFile = Files(iFile)
Dim FileName, FileExtent As String
FileName = Serverpath System.IO.Path.GetFileName(PostedFile.FileName)
If System.IO.Path.GetFileName(PostedFile.FileName) "" Then
FileName = System.IO.Path.GetFileName(PostedFile.FileName)
Dim Url As String = Me.Label1.Text.Trim FileName
PostedFile.SaveAs(Serve
vb.net如何使用HttpWebRequest模拟登陆带验证码的网站
一般登陆网站时候首先要打开一个网页对吧?
那首先要 GET 一个网址。GetResponse后,得到的流就是这个页面的源码。
源码里肯定会包含这个验证码的提问段(可能是个图片的网址,也可能是个 5+5=? 之类的字符串之类的),可以分析一下这段代码出现的位置,让程序自动寻找。找到这个图片的网址,把这个图片 GET 下来,然后,就是orc识别或你人工识别咯。。。
vb.net/.net怎样使用http协议的get和post?
建立ODBC数据源后,可以在Java程序中通过JDBC-ODBC接口连接数据裤:
//SQL Server
DriverManager.getConnection(''jdbc:sqlserver://主机\\实例名:端口号;
DatabaseName=数据库名'',''用户名'',''密码'')
文章标题:关于vb.net中http的信息
分享路径:http://scjbc.cn/article/dophcsh.html