get value from web page

User avatar
sal21
PlatinumLounger
Posts: 4169
Joined: 26 Apr 2010, 17:36

get value from web page

Post by sal21 »

I use IE object.

how to get this value in bold:

<div class="row rowPaginazione fsStd">
<div class="col-md-3">
Pagina 1 di 163
</div>

the link:
https://www.comuniecitta.it/comuni-italiani?pg1

User avatar
SpeakEasy
3StarLounger
Posts: 319
Joined: 27 Jun 2021, 10:46

Re: get value from web page

Post by SpeakEasy »

Have a look at the getElementsByClassName function, e.g.

Code: Select all

    Dim IE As New InternetExplorer
    Dim divclass As Object
  
    IE.navigate "https://www.comuniecitta.it/comuni-italiani?pg1"
    Set divclass = IE.document.getElementsByClassName("col-md-3")
    MsgBox Trim(Right(divclass(0).innerText, 4))

User avatar
sal21
PlatinumLounger
Posts: 4169
Joined: 26 Apr 2010, 17:36

Re: get value from web page

Post by sal21 »

SpeakEasy wrote:
22 Nov 2022, 12:24
Have a look at the getElementsByClassName function, e.g.

Code: Select all

    Dim IE As New InternetExplorer
    Dim divclass As Object
  
    IE.navigate "https://www.comuniecitta.it/comuni-italiani?pg1"
    Set divclass = IE.document.getElementsByClassName("col-md-3")
    MsgBox Trim(Right(divclass(0).innerText, 4))
TKS BRO. work.

idea to submit the button CERCA.?

link:
https://www.codiceinverso.it/servizi/codice-istat.html

put in "Inserisci il codice Istat"

a value similar 001001, and click on button cerca
You do not have the required permissions to view the files attached to this post.

User avatar
SpeakEasy
3StarLounger
Posts: 319
Joined: 27 Jun 2021, 10:46

Re: get value from web page

Post by SpeakEasy »

For this specific example. something like:

Code: Select all

    Dim IE As New InternetExplorer
    Dim element As HTMLButtonElement
  
    IE.navigate "https://www.codiceinverso.it/servizi/codice-istat.html"
    
    ' shoukd really wait for page to complete loading
    Do Until IE.readyState = READYSTATE_COMPLETE
        DoEvents
    Loop

    For Each element In IE.document.getElementsByTagName("input")
        If element.Name = "istat" Then element.Value = "001001"
    Next


    For Each element In IE.document.getElementsByClassName("btn-submit") 'objCollection
        If element.Type = "submit" And element.innerText = "Cerca" Then element.Click   ' click button
    Next
    
    ' should really wait for page to complete loading
    Do Until IE.readyState = READYSTATE_COMPLETE
        DoEvents
    Loop
    
    ' At this point IE should have the new page
    ' so do stuff

    IE.Quit 'clean up

User avatar
sal21
PlatinumLounger
Posts: 4169
Joined: 26 Apr 2010, 17:36

Re: get value from web page

Post by sal21 »

SpeakEasy wrote:
24 Nov 2022, 10:37
For this specific example. something like:

Code: Select all

    Dim IE As New InternetExplorer
    Dim element As HTMLButtonElement
  
    IE.navigate "https://www.codiceinverso.it/servizi/codice-istat.html"
    
    ' shoukd really wait for page to complete loading
    Do Until IE.readyState = READYSTATE_COMPLETE
        DoEvents
    Loop

    For Each element In IE.document.getElementsByTagName("input")
        If element.Name = "istat" Then element.Value = "001001"
    Next


    For Each element In IE.document.getElementsByClassName("btn-submit") 'objCollection
        If element.Type = "submit" And element.innerText = "Cerca" Then element.Click   ' click button
    Next
    
    ' should really wait for page to complete loading
    Do Until IE.readyState = READYSTATE_COMPLETE
        DoEvents
    Loop
    
    ' At this point IE should have the new page
    ' so do stuff

    IE.Quit 'clean up
great!
tks.

User avatar
sal21
PlatinumLounger
Posts: 4169
Joined: 26 Apr 2010, 17:36

Re: get value from web page

Post by sal21 »

SpeakEasy wrote:
22 Nov 2022, 12:24
Have a look at the getElementsByClassName function, e.g.

Code: Select all

    Dim IE As New InternetExplorer
    Dim divclass As Object
  
    IE.navigate "https://www.comuniecitta.it/comuni-italiani?pg1"
    Set divclass = IE.document.getElementsByClassName("col-md-3")
    MsgBox Trim(Right(divclass(0).innerText, 4))
sorry bro...
now i need to get AG, uder a little arrow of image, are same parameter or not?

link page:
https://www.tuttitalia.it/sicilia/provi ... agrigento/
You do not have the required permissions to view the files attached to this post.