Accessing WoT API Server

Post Reply
User avatar
Posts: 1
Joined: Thu Jul 27, 2017 2:54 pm

Accessing WoT API Server

Post by Coffee_ » Tue Aug 01, 2017 4:03 pm

More info for here: about the API.

This code downloads and cleans up the data from world of tanks dev api interface.

Code: Select all

#Region "imports"
Imports System.Windows
Imports System.Windows.Forms
Imports System.Drawing
Imports System.Drawing.Drawing2D
Imports System.Net
Imports System.Text
Imports System.IO
Imports System.Xml
Imports System.Web
Imports Tao.OpenGl
Imports Tao.Platform.Windows
Imports Tao.FreeGlut
Imports Tao.FreeGlut.Glut
Imports Microsoft.VisualBasic.Strings
Imports System.Math
Imports System.Object
Imports System.Threading
Imports System.Data
Imports Tao.DevIl
Imports System.Runtime.InteropServices
Imports System.Runtime.CompilerServices
Imports System.Collections.Generic
Imports Ionic.Zip
Imports System.Drawing.Imaging

#End Region

Module WOT_Dev_interface
    Public in_tags As String
    Public in_names As String
    Public in_shortnames As String
    Public in_nations As String
    Public tank_list(1) As tankitem_
    Public TankDataTable As New DataTable
    Public Structure tankitem_
        Public path As String
        Public tier As String
        Public short_name As String
        Public nation As String
    End Structure
    Public Sub get_tank_names()
        frmMain.info_Label.Text = "Connecting to WoT Api Server"
        Dim client As New WebClient
        Dim tags As String = ""
        Dim tiers As String = ""
        Dim shortnames As String = ""
        Dim nations As String = ""

        Dim reader As New StreamReader(client.OpenRead(tags))
        frmMain.info_Label.Text = "Getting Tags..."

        in_tags = reader.ReadToEnd

        frmMain.info_Label.Text = "Getting Tiers..."
        reader = New StreamReader(client.OpenRead(tiers))
        in_names = reader.ReadToEnd

        frmMain.info_Label.Text = "Getting shortnames..."
        reader = New StreamReader(client.OpenRead(shortnames))
        in_shortnames = reader.ReadToEnd

        frmMain.info_Label.Text = "Getting nations..."
        reader = New StreamReader(client.OpenRead(nations))
        in_nations = reader.ReadToEnd


        'frmMain.info_Label.Text = "Building Tank Table..."

        For Each q In tank_list
            Dim r = TankDataTable.NewRow
            r("tag") = q.path
            r("shortname") = q.short_name
            r("tier") = q.tier
            r("nation") = q.nation
            Dim outs As String = q.nation + ";" + q.tier + ";" + q.path + ";" + q.short_name + vbCrLf


    End Sub

    Public Sub build_look_table()
        Dim tags() As String
        Dim tiers() As String
        Dim shortnames() As String
        Dim nations() As String
        tags = clean_file(in_tags)
        tiers = clean_file(in_names)
        shortnames = clean_file(in_shortnames)
        nations = clean_file(in_nations)
        ReDim tank_list(tags.Length)
        For i = 0 To tags.Length - 1
            tank_list(i) = New tankitem_
            tank_list(i).path = tags(i)
            tank_list(i).tier = tiers(i)
            tank_list(i).short_name = shortnames(i)
            tank_list(i).nation = nations(i)
    End Sub
    Public Function clean_file(ByRef st As String) As Array
        Dim ts As String = st.Replace("data" + """" + ":", "!")
        ts = ts.Replace("8,8", "8.8") ' causes issues with spitting the data
        ts = ts.Replace("}}", "")
        Dim ar = ts.Split("!")
        ts = ar(1)
        ar = ts.Split(",")
        Dim cnt As Integer = 0
        For Each a In ar
            Dim sa = a.Split(":")
            Dim s = sa(2).Replace("}", "")
            s = s.Replace("""", "")
            ar(cnt) = s
            cnt += 1
        Return ar
    End Function

End Module
I'd love to change the world but I can't get my hands on the source code.Image

Post Reply