Announcement

Collapse
No announcement yet.

Using hs.geturl with logging in?

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    Using hs.geturl with logging in?

    Hi all,

    i have a script to retrieve data from a website.

    How can i use it when i need to login first?

    here is an example what i have:
    https://my.example.com brings me to the login page.

    when i inspect the code of the login site i see that it uses this to login :

    My email login
    Code:
    <input class="form-control" data-val="true" data-val-required="Your username required!" id="UserName" name="UserName" placeholder="Your E-mailadres here " type="text" value="">
    My password login
    Code:
    <input class="form-control" data-val="true" data-val-required="Password Needed!" id="Password" name="Password" placeholder="Your password here" type="password">
    Submit
    Code:
    <input type="submit" class="btn btn-default purple" border="0" value="Login">


    This is the script i use but need help to put login in there.
    Code:
    Sub Main(ByVal Parms As Object)
    
      Dim strSite = "https://my.example.com/"
      Dim strDocument =  ""
      Dim strBody
      Dim x
    
    strBody = hs.GetUrl(strSite,strDocument,false,80)
    
      
    
      x = Instr(1,strBody,"header2",+1) 
      strBody = Mid(strBody,x)
      x = Instr(1,strBody, "<p>",1) + 3
      strBody = Mid(strBody,x)
      x = Instr(1,strBody, "<",1) - 1
      strBody = Mid(strBody,1,x)
      hs.writelog("debug", strbody)
    
    
    end sub
    Regards
    Preferred -> Jon's Plugins, Pushover, Phlocation, Easy-trigger,
    Rfxcom, Blade Plugins, Pushbullet, homekit, Malosa Scripts




    HS3Pro 4.0.8.0 on windows 10 enterprise X64 on hp quadcore laptop 8 GB.

    #2
    It is not quite as simple as that, if the site uses basic authentication then that is fairly easy to get around by adding the header. I suspect that instead it is using some sort of proper login which you will need to debug as there may be authentication headers that need to be added, it would be guesswork without seeing the page.

    Comment


      #3
      Hi Adam

      Thanx for the reply

      Pm sended



      Originally posted by mrhappy View Post
      It is not quite as simple as that, if the site uses basic authentication then that is fairly easy to get around by adding the header. I suspect that instead it is using some sort of proper login which you will need to debug as there may be authentication headers that need to be added, it would be guesswork without seeing the page.
      Preferred -> Jon's Plugins, Pushover, Phlocation, Easy-trigger,
      Rfxcom, Blade Plugins, Pushbullet, homekit, Malosa Scripts




      HS3Pro 4.0.8.0 on windows 10 enterprise X64 on hp quadcore laptop 8 GB.

      Comment


        #4
        I've had a look at that page and I am afraid it is well outside of my ability levels, it uses some Javascript and whilst I can see how it is logging in it is using request tokens and such like (this is an example: __RequestVerificationToken:cXJjPStvxtFmrhVn_0nKRkQCnZ2mUOR1H iDAOtL4qjb6iieqJPfAfuAp_PgVvRuu4JLiaj1zgUyU3KJlV18o19_hQv01 UserName:a@a.com Password:test - no idea how it is generating that token, it might be generated when the page first loads) that I don't imagine you will get around particularly easily. I would look and see whether they have a published API to gain access to the data you want, that will certainly be easier.

        If you are in Chrome press F12 on the web page and then try and login, you will see the data being exchanged when you login and you will see there is quite a bit.

        Comment


          #5
          thanks for the reply,

          Yes i see it , it uses a verification token and its random everytime u try to refresh the page, so it gets generated when the page first loads.


          they dont have an api

          is it possible to stay logged in somehow ?
          because if i login on iexplorer on my server where homeseer is and leave it logged in, then when i try it with the script it needs to login again but when i check the website on iexplorer is still open and works normal without logging in.

          Originally posted by mrhappy View Post
          I've had a look at that page and I am afraid it is well outside of my ability levels, it uses some Javascript and whilst I can see how it is logging in it is using request tokens and such like (this is an example: __RequestVerificationToken:cXJjPStvxtFmrhVn_0nKRkQCnZ2mUOR1H iDAOtL4qjb6iieqJPfAfuAp_PgVvRuu4JLiaj1zgUyU3KJlV18o19_hQv01 UserName:a@a.com Password:test - no idea how it is generating that token, it might be generated when the page first loads) that I don't imagine you will get around particularly easily. I would look and see whether they have a published API to gain access to the data you want, that will certainly be easier.

          If you are in Chrome press F12 on the web page and then try and login, you will see the data being exchanged when you login and you will see there is quite a bit.
          Preferred -> Jon's Plugins, Pushover, Phlocation, Easy-trigger,
          Rfxcom, Blade Plugins, Pushbullet, homekit, Malosa Scripts




          HS3Pro 4.0.8.0 on windows 10 enterprise X64 on hp quadcore laptop 8 GB.

          Comment

          Working...
          X