mercredi 2 mai 2018

web page scraping automatic login vb

The following vb code tries to login to a website :

Dim IE As New SHDocVw.InternetExplorer
Dim HTMLDoc As MSHTML.HTMLDocument
Dim HTMLElement As MSHTML.IHTMLElement

IE.Visible = True

IE.navigate ("https://www.website.com/login")
Do While IE.ReadyState <> READYSTATE_COMPLETE: Loop
Set HTMLDoc = IE.Document

HTMLDoc.all("loginForm-email").Value = "email@address.com"
HTMLDoc.all("loginForm-password").Value = "password"
HTMLDoc.all("loginForm-submit").Click

The emails address and password display correctly on the web page, however when pressing the login button, it errors as if there is no data entered, this is because there is some validation that it is not getting triggered by the vb script.

I noticed the attributes of some "IHTMLElement" are set by default to :

"has-feedback form-group has-error pristine untouched ember-view"

... and are changed, when entering the email & password manually, to :

"has-feedback form-group has-success pristine touched ember-view"

.... but are not changed by the vb script above ?

Any ideas, are most welcome.




Aucun commentaire:

Enregistrer un commentaire