Hello Guys我需要你的帮助我想在http响应中读取json这是响应
{"响应" {" SESSION_ID":" lku1ui1dr3ff4p2q4agmcd0jd3"" EXPIRE_DATE":1527950247," traffic_left&#34 ;:" 13032101083573"}" response_status":200," response_details":空}
这是发布数据的示例数据
POST示例/ api / user / login HTTP / 1.1
接受: /
User-Agent:Mozilla / 5.0(Windows; U; Windows NT 5.1; en) AppleWebKit / 522.11.3(KHTML,与Gecko一样)Version / 3.0 Safari / 522.11.3
主持人:example.net
Pragma:no-cache
连接:保持活力
Content-Type:application / x-www-form-urlencoded Content-Length:46
用户名=示例&安培;密码= 1234456
我想阅读"expire_date":
,如果它存在,那么它会
Dim expiredate as string
Public Sub method_5()
Dim proxyAddress As String = Me.string_1(Me.random_0.[Next](0, Me.int_1)),
While Me.queue_0.Count > 0
Dim obj As Object = Me.object_0
Dim flag As Boolean = False
Dim obj2 As Object
Dim text As String
Try
Dim expr_29 As Object = obj
obj2 = expr_29
Monitor.Enter(expr_29, flag)
Try
text = Me.queue_0.Peek().ToString().TrimEnd(New Char() {vbCr}).Trim()
Me.queue_0.Dequeue()
Catch ex As Exception
End Try
Finally
If flag Then
#Disable Warning BC42104 ' Variable is used before it has been assigned a value
Monitor.[Exit](obj2)
#Enable Warning BC42104 ' Variable is used before it has been assigned a value
End If
End Try
Dim array As String() = text.Split(New Char() {":"})
Try
Using httpRequest As HttpRequest = New HttpRequest()
httpRequest.Proxy = ProxyClient.Parse(Me.proxyType_0, proxyAddress)
Dim cookies As CookieDictionary = New CookieDictionary(False)
httpRequest.Cookies = cookies
httpRequest.IgnoreProtocolErrors = True
httpRequest.ConnectTimeout = 25000
httpRequest.AllowAutoRedirect = True
httpRequest.KeepAlive = True
httpRequest.UserAgent = Http.ChromeUserAgent()
httpRequest.AddParam("username", array(0))
httpRequest.AddParam("password", array(1))
Dim text2 As String = httpRequest.Post("<website>").ToString()
If text2.Contains("") Then
End If
obj = Me.object_0
Dim flag2 As Boolean = False
Try
Dim expr_222 As Object = obj
obj2 = expr_222
Monitor.Enter(expr_222, flag2)
#Disable Warning BC42025 ' Access of shared member, constant member, enum member or nested type through an instance
array.Resize(Of String)(Me.string_2, Me.int_2 + 1)
#Enable Warning BC42025 ' Access of shared member, constant member, enum member or nested type through an instance
#Disable Warning BC42104 ' Variable is used before it has been assigned a value
Me.string_2(Me.int_2) = +text + "|Subscription: "
#Enable Warning BC42104 ' Variable is used before it has been assigned a value
Me.int_2 += 1
Me.int_5 += 1
Me.int_6 -= 1
Continue While
Finally
If flag2 Then
Monitor.[Exit](obj2)
End If
End Try
obj = Me.object_0
Dim flag3 As Boolean = False
Try
Dim expr_29E As Object = obj
obj2 = expr_29E
Monitor.Enter(expr_29E, flag3)
Me.int_3 += 1
Finally
If flag3 Then
Monitor.[Exit](obj2)
End If
End Try
Me.int_5 += 1
Me.int_6 -= 1
End Using
Catch
Me.int_7 += 1
Me.queue_0.Enqueue(text)
proxyAddress = Me.string_1(Me.random_0.[Next](0, Me.int_1))
End Try
End While
If Me.int_5 = Me.int_0 Then
Me.method_6()
End If
End Sub
请注意,不要错过这些错误导致它不是完整代码的一部分
答案 0 :(得分:0)
我相信这与您所寻找的类似:
Dim req As HttpWebRequest = WebRequest.Create("www.SomeURL.com/?username=somevalue&password=somevalue")
Dim resp As HttpWebResponse = req.GetResponse()
Dim enc As Encoding = System.Text.Encoding.GetEncoding(1252)
Dim loResponseStream As StreamReader = New StreamReader(resp.GetResponseStream(), enc)
Dim Response As String = loResponseStream.ReadToEnd()
Dim jss As JavaScriptSerializer = New JavaScriptSerializer()
Dim dict As Object = jss.Deserialize(Of Dictionary(Of String, Object))(Response)
Dim expiredate As String = (dict("session_id")("expire_date")) 'You may need to play with this to get the value, wrote this off the top of my head ...
loResponseStream.Close()