Using client As New Net.WebClient
Dim reqparm As New Specialized.NameValueCollection
'reqparm.Add("param1", "somevalue")
'reqparm.Add("param2", "othervalue")
Dim responsebytes = client.UploadValues("http://ip2country.sourceforge.net/ip2c.php?format=JSON", "POST", reqparm)
Dim responsebody = (New Text.UTF8Encoding).GetString(responsebytes)
End Using在以下方面的成果:
{ip:"184.23.135.130",主机名:“184-23-135-130”,country_code:"US",country_name:"United States"}
寻求任何帮助
发布于 2014-07-30 16:33:59
我想通了。我包括了Json.net参考资料。
Imports Newtonsoft.Json.Linq
Imports System.Net
Using client As New Net.WebClient
Dim reqparm As New Specialized.NameValueCollection
'reqparm.Add("param1", "somevalue")
'reqparm.Add("param2", "othervalue")
Dim responsebytes = client.UploadValues("http://ip2country.sourceforge.net/ip2c.php?format=JSON", "POST", reqparm)
Dim responsebody = (New Text.UTF8Encoding).GetString(responsebytes)
Dim blah As String = client.DownloadString("http://ip2country.sourceforge.net/ip2c.php?format=JSON")
Dim json As JObject = JObject.Parse(responsebody)
Console.WriteLine(json.SelectToken("ip"))
Console.WriteLine(json.SelectToken("hostname"))
Console.WriteLine(json.SelectToken("country_code"))
Console.WriteLine(json.SelectToken("country_name"))
Console.ReadKey()
End Usinghttps://stackoverflow.com/questions/25024049
复制相似问题