VBA e Web: automatizzare l'autenticazione a un sito web.

Anonimo
2013-08-06T08:25:16+00:00

Buongiorno a tutti, 

rieccoci con un nuovo problema di interazione tra Visual Basic ed Internet Explorer. Devo scrivere uno script che esegua l'accesso al seguente sito web: https://ibiznes24.pl/bzwbk24biznes-client/login.html

Tuttavia, ho i seguenti problemi:

  • Dopo aver inserito il codice 11111111 nel campo "Podaj NIK", non riesco ad uscirne per poter premere il bottone "Dalej". In pratica, il seguente codice:

Set ElementCol = appIE.document.getElementsByClassName("x-btn-text")

For Each btnInput In ElementCol

If btnInput.innerText = "Dalej" Then

btnInput.Click

Exit For

End If

Next btnInput

tecnicamente funziona, ma in realta' l'esecuzione non porta a nessun risultato in quanto il bottone "Dalej" non e' attivo dopo aver compilato il          primo campo, bisognerebbe infatti cliccare a vuoto sulla pagina.

  • La password da inserire e' strana, in quanto bisogna riempire solo i campi disponibili (basta cliccare sul bottone "Dalej" per vedere la struttura). Anche in questo caso ho scritto un codice che, per logica, dovrebbe funzionare (quello incollato sotto riempie il primo campo se disponibile):
  • Set ElementCol = appIE.document.getElementsByTagName("input")
  • For Each btnInput In ElementCol
  • If (btnInput.ID = "x-auto-13") And (btnInput.className = "enabled x-component") Then
  • btnInput.Value = "A"
  • Exit For
  • End If
  • Next btnInput
  • Tuttavia, anche questo codice non sembra funzionare.

Qualcuno sa aiutarmi? Grazie in anticipo!!!

Microsoft 365 e Office | Excel | Per la casa | Windows

Domanda bloccata. Questa domanda è stata eseguita dalla community del supporto tecnico Microsoft. È possibile votare se è utile, ma non è possibile aggiungere commenti o risposte o seguire la domanda.

0 commenti Nessun commento
Risposta accettata dall'autore della domanda
Anonimo
2013-08-09T15:36:10+00:00

Ciao Matteo,

in relazione alla tua domanda, per una migliore assistenza, prova a postarla anche nel Microsoft Visual Basic Forum, appositamente creato per gli sviluppatori VB.

Saluti,

Inga

La risposta è stata utile?

0 commenti Nessun commento

3 risposte aggiuntive

Ordina per: Più utili
  1. Anonimo
    2013-08-12T07:56:18+00:00

    Ciao Matteo,

    grazie a te per il feedback.

    Buone ferie!

    Inga

    La risposta è stata utile?

    0 commenti Nessun commento
  2. Anonimo
    2013-08-09T15:52:50+00:00

    Ciao Inga,

    grazie per il suggerimento, provero' li' al ritorno dalle ferie! Ti auguro una buona giornata!

    La risposta è stata utile?

    0 commenti Nessun commento
  3. Anonimo
    2013-08-06T08:29:16+00:00

    Codice intero (pronto per essere eseguito da una macro):


    Sub DownloadBzwbk()

    Dim appIE As Object ' InternetExplorer.Application

    Dim sURL As String

    Dim UserN As Object ' MSHTML.IHTMLElement

    Dim PW As Object ' MSHTML.IHTMLElement

    Dim PW2 As Object

    Dim Testo As Object

    Dim Element As Object ' HTMLButtonElement

    Dim btnInput As Object ' MSHTML.HTMLInputElement

    Dim ElementCol As Object ' MSHTML.IHTMLElementCollection

    Dim Link As Object ' MSHTML.HTMLAnchorElement

    Dim strCountBody As String

    Dim lStartPos As Long

    Dim lEndPos As Long

    Dim TextIWant As String

    Dim GetIE As Object

    Set GetIE = CreateObject("internetexplorer.application")

    Application.ScreenUpdating = False

    Set appIE = GetIE

    'On Error GoTo Messaggiodierrore

    sURL = "https://ibiznes24.pl/bzwbk24biznes-client/login.html"

    With appIE

    .navigate sURL

    'togli il commento alla linea sotto per vedere il web

    .Visible = True

    End With

    Do While appIE.Busy

    Loop

    newHour = Hour(Now())

    newMinute = Minute(Now())

    newSecond = Second(Now()) + 3

    waitTime = TimeSerial(newHour, newMinute, newSecond)

    Application.Wait waitTime

    Set ElementCol = appIE.document.getElementsByTagName("input")

    For Each btnInput In ElementCol

    If btnInput.ID = "x-auto-2-input" Then

    btnInput.Value = "11111111"

    Exit For

    End If

    Next btnInput

    Do While appIE.Busy

    Loop

    newHour = Hour(Now())

    newMinute = Minute(Now())

    newSecond = Second(Now()) + 3

    waitTime = TimeSerial(newHour, newMinute, newSecond)

    Application.Wait waitTime

    Set ElementCol = appIE.document.getElementsByClassName("x-btn-text")

    For Each btnInput In ElementCol

    If btnInput.innerText = "Dalej" Then

    btnInput.Click

    Exit For

    End If

    Next btnInput

    Do While appIE.Busy

    Loop

    newHour = Hour(Now())

    newMinute = Minute(Now())

    newSecond = Second(Now()) + 2

    waitTime = TimeSerial(newHour, newMinute, newSecond)

    Application.Wait waitTime

    Set ElementCol = appIE.document.getElementsByTagName("input")

    For Each btnInput In ElementCol

    If (btnInput.ID = "x-auto-13") And (btnInput.className = "enabled x-component") Then

    btnInput.Value = "A"

    Exit For

    End If

    Next btnInput

    End Sub

    La risposta è stata utile?

    0 commenti Nessun commento