martes, 4 de junio de 2019

Scrape WEB - send to Excel

the link shows the function

QueryTables.Add method (Excel)

https://docs.microsoft.com/en-us/office/vba/api/excel.querytables.add

Save the Macro meanwhile executing the Data Connection from Web
Then modify the Macro in order to read each page.

http://calculationsolar.com/es/componentes_inversores_cargadores.php?pagina=4
http://calculationsolar.com/es/componentes_inversores_cargadores.php?pagina=5
http://calculationsolar.com/es/componentes_inversores_cargadores.php?pagina=6
http://calculationsolar.com/es/componentes_inversores_cargadores.php?pagina=7
http://calculationsolar.com/es/componentes_inversores_cargadores.php?pagina=8

Sub Macro2()
    With ActiveSheet.QueryTables.Add(Connection:= _
        "URL;http://calculationsolar.com/es/componentes_inversores_cargadores.php?pagina=4" _
        , Destination:=Range("$A$1"))
        .Name = "componentes_inversores_cargadores.php?pagina=4"
        .FieldNames = True
        .RowNumbers = False
        .FillAdjacentFormulas = False
        .PreserveFormatting = True
        .RefreshOnFileOpen = False
        .BackgroundQuery = True
        .RefreshStyle = xlInsertDeleteCells
        .SavePassword = False
        .SaveData = True
        .AdjustColumnWidth = True
        .RefreshPeriod = 0
        .WebSelectionType = xlEntirePage
        .WebFormatting = xlWebFormattingNone
        .WebPreFormattedTextToColumns = True
        .WebConsecutiveDelimitersAsOne = True
        .WebSingleBlockTextImport = False
        .WebDisableDateRecognition = False
        .WebDisableRedirections = False
        .Refresh BackgroundQuery:=False
    End With
End Sub

Same results

Sub Macro2()
    With ActiveSheet.QueryTables.Add(Connection:= _
        "URL;http://calculationsolar.com/es/componentes_inversores_cargadores.php?pagina=4" _
        , Destination:=Range("$A$1"))
    End With
End Sub


No hay comentarios:

Publicar un comentario