No announcement yet.

get information from

  • Filter
  • Time
  • Show
Clear All
new posts

  • get information from

    I have solar panels from growatt and want to input the readings in HS devices.
    But to get the info, I have to login to their website:
    How can I make a .vb script to login and get my information?
    I know I can get a website in a variable wit hs.GetURL, but I don't know how I can login first.

  • #2
    Found this code on the web.
    But I don't know if I first must make a connection to the website followed by this code.
    Can I run this with userName and password at once, or do I have to run the code for username and again for password?

    Who has experience getting data from a website that needs a login?

    Imports System.IO
    Imports System.Net
    Imports System.Text
    Sub Main(parm As Object)
        Const debug = True
        Const server = ""
        Const postData = "userName=naam&password=wachtwoord"
         ' Create a request using a URL that can receive a post.  
        Const server_url = "https://" & server & "/login"
        Dim request As WebRequest = WebRequest.Create(server_url)
        ' Set the Method property of the request to POST.  
        request.Method = "POST"
        ' Create POST data and convert it to a byte array.  
        Dim byteArray As Byte() = Encoding.UTF8.GetBytes(postData)
         ' Set the ContentType property of the WebRequest.  
        request.ContentType = "application/x-www-form-urlencoded"
        ' Set the ContentLength property of the WebRequest.  
        request.ContentLength = byteArray.Length
        ' Get the request stream.  
        Dim dataStream As Stream = request.GetRequestStream()
        ' Write the data to the request stream.  
        dataStream.Write(byteArray, 0, byteArray.Length)
        ' Close the Stream object.  
        ' Get the response.  
        Dim response As WebResponse = request.GetResponse()
        ' Display the status.  
        If debug Then hs.writelog("POST request", CType(response, HttpWebResponse).StatusDescription)
        ' Get the stream containing content returned by the server.  
        dataStream = response.GetResponseStream()
        ' Open the stream using a StreamReader for easy access.  
        Dim reader As New StreamReader(dataStream)
        ' Read the content.  
        Dim responseFromServer As String = reader.ReadToEnd()
        ' Display the content.  
        If debug Then hs.writelog("POST response", responseFromServer)
        ' Clean up the streams.  
    End Sub


    • #3
      Have you looked at Jon00's data scraper script?
      Mike____________________________________________________________ __________________
      HS3 Pro Edition

      HW: Stargate | NX8e | CAV6.6 | Squeezebox | PCS | WGL 800RF, Rain8Net+ | RFXCOM | QSE100D | Vantage Pro | Green-Eye | X10: XTB-232, -IIR | Edgeport/8 | Way2Call | Ecobee3


      • #4
        Originally posted by Uncle Michael View Post
        Have you looked at Jon00's data scraper script?
        I have tested his script.
        The problem is that I have to login first and then go to another page for the data.....