我们可以在 WebViewClient 的 onPageFinished(WebView view, String url) 方法中使用 CookieManager 来获取加载完成之后网页中携带的 Cookie 值,代码如下:private class MyWebViewClient extends WebViewClient { public boolean shouldOverrideUrlLoading(WebView view, String url) { webviewloadUrl(url); return true; } public void onPageFinished(WebView view, String url) { CookieManager cookieManager = CookieManagergetInstance(); String CookieStr = cookieManagergetCookie(url); Loge("sunzn", "Cookies = " + CookieStr); superonPageFinished(view, url); } }
这个问题有点意思,但题主表意不明,确切的说应该分Web端和客户端两种情况。
想来问到这个问题的不应该是开发Web端的,说说客户端的吧:
1、>
VBNET >
嘿嘿,试试下面这个api
Private Const INTERNET_COOKIE_另外,再给你一个函数
''' <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()
DebugPrint($"过程:{New StackTrace()GetFrame(0)GetMethodName} 转换cookie开始")
Try
Dim cookstr As String() = cookieStrSplit(";"c)
Dim cookieName As String = ""
Dim cookieValue As String = ""
For Each str As String In cookstr
cookieName = strSubstring(0, InStr(str, "=") - 1)Trim()
cookieValue = strSubstring(InStr(str, "="), strLength - InStr(str, "="))Trim()
Dim ck As New Cookie(cookieName, cookieValue)
'DebugPrint($"{cookieName} = {cookieValue}")
ckDomain = domain
cookieAdd(ck)
Next
DebugPrint($"过程:{New StackTrace()GetFrame(0)GetMethodName} 转换cookie成功")
Catch ex As Exception
DebugPrint($"过程:{New StackTrace()GetFrame(0)GetMethodName} {exStackTraceToString()}")
Finally
DebugPrint($"过程:{New StackTrace()GetFrame(0)GetMethodName} 转换cookie结束")
End Try
End Sub
以上就是关于android webview加载页面怎么得到cookies值全部的内容,包括:android webview加载页面怎么得到cookies值、vb.net如何获取网页的cookie、用电脑浏览器获取京东cookie教程-青龙面板等相关内容解答,如果想了解更多相关内容,可以关注我们,你们的支持是我们更新的动力!
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)