hackoo

Covid-19_Infos.vbs

Aug 1st, 2021
1,945
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. Option Explicit
  2. Dim Title,Countries_Array,Country,URL,strJSON,Data
  3. Dim Cases,Deaths,Recoverd,Active,Tests,Critical,Info
  4. Title = "Covid-19 Informations by Hackoo 2021"
  5. 'Forcing Cscript engine execution
  6. Call ForceCScriptExecution(Title)
  7.  
  8. Countries_Array = Array("Nepal","Iran","Turkey","Germany","UAE","US",_
  9. "Syria","russia","Mexico","France","Brazil","India","Italy","Spain","Colombia","Argentina",_
  10. "Egypt","Algeria","Morocco","Libya","Tunisia")
  11.  
  12. For Each Country in Countries_Array
  13.     URL = "https://disease.sh/v3/covid-19/countries/"& Country
  14.     strJSON = GetJSON(URL)
  15.     Set Data = Parse(strJson)
  16.     Country = Data.country
  17.     Cases = Data.cases
  18.     Deaths = Data.deaths
  19.     Recoverd = Data.recovered
  20. 'flag = Data.countryInfo.flag
  21.     Active = Data.active
  22.     Tests = Data.tests
  23.     Critical = Data.critical
  24.     Info = Info & vbCrLf & string(25,"-") & vbCrLF
  25.     Info = Info & Country & vbCrLF &_
  26.     Convert2Date(Data.updated) & vbCrLF &_
  27.     string(25,"-") & vbCrLf &_
  28.     "Tests       : " & Tests    & vbCrLF &_
  29.     "Total Cases : " & Cases    & vbCrLF &_
  30.     "Actives     : " & Active   & vbCrLF &_
  31.     "Deaths      : " & Deaths   & vbCrLF &_
  32.     "critical    : " & Critical & vbCrLF &_
  33.     "Recoverd    : " & Recoverd & vbCrLF &_
  34.     string(25,"-") & vbCrLF
  35. Next
  36. wscript.echo Info
  37. '-----------------------------------------------------------------------------------
  38. Function CurrentTZOffset()
  39.     With CreateObject("WScript.Shell")
  40.         CurrentTZOffset = - .RegRead( _
  41.         "HKLM\System\CurrentControlSet\Control\TimeZoneInformation\ActiveTimeBias")
  42.     End With
  43. End Function
  44. '-----------------------------------------------------------------------------------
  45. Function Convert2Date(Epoch)
  46.     Dim dblVbEpoch
  47.     dblVbEpoch = CDbl(DateAdd("s", Epoch/1000, #1970/1/1#))
  48.     Convert2Date = DateAdd("n", CurrentTZOffset(), CDate(dblVbEpoch))'VB Date (LOCAL)
  49. 'VB Date (GMT) ==> Convert2Date = CDate(dblVbEpoch)
  50. End Function
  51. '----------------------------------------------------------------------------------
  52. Function GetJSON(URL)
  53.     On Error Resume Next
  54.     Dim http
  55.     Set http = CreateObject("WinHttp.WinHttpRequest.5.1")
  56.     http.open "GET",URL,False
  57.     http.Send
  58.     GetJSON = http.responseText
  59. End Function
  60. '----------------------------------------------------------------------------------
  61. Function Parse(strJson)
  62.     Dim html,window
  63.     Set html = CreateObject("htmlfile")
  64.     Set window = html.parentWindow
  65.     window.execScript "var json = " & strJson, "JScript"
  66.     Set Parse = window.json
  67. End Function
  68. '----------------------------------------------------------------------------------
  69. Sub ForceCScriptExecution(Title)
  70.     Dim Arg, Str, cmd
  71.     cmd = "CMD /k Title " & Title &" & color 0A & "
  72.     If Not LCase( Right( WScript.FullName, 12 ) ) = "\cscript.exe" Then
  73.         For Each Arg In WScript.Arguments
  74.             If InStr( Arg, " " ) Then Arg = """" & Arg & """"
  75.             Str = Str & " " & Arg
  76.         Next
  77.         CreateObject( "WScript.Shell" ).Run _
  78.         cmd & "cscript //nologo """ & _
  79.         WScript.ScriptFullName & _
  80.         """ " & Str
  81.         WScript.Quit
  82.     End If
  83. End Sub
  84. '----------------------------------------------------------------------------------
RAW Paste Data