1

I'm trying to import data For a large number of dates from here: https://demanda.ree.es/movil/peninsula/demanda/tablas/2014-11-03/2

Once/if that's possible I want to automate it so it retrieves the data for a given set of dates. Say, entire 2013.

I can't find anything in the webpage source that would give a hint as to from where the data is retrieved from. I've tried importing the data both using:

Data/From Web: Gets javascript error

Open/ Other web locations: Just retrieves a worksheet filled with grey cells, no data.

Thanks for any help!

1
  • Upon closer exmination I now found this part in the source code: lib/jquery/table2CSV.js But I can't locate any table2CSV.csv nor table2.csv (?) in any subfolder. Commented Nov 11, 2014 at 8:41

2 Answers 2

1

Use the following links:

https://demanda.ree.es/WSvisionaMovilesPeninsulaRest/resources/maxMinPeninsula?callback=angular.callbacks._0&curva=DEMANDA&fecha=2013-01-01

https://demanda.ree.es/WSvisionaMovilesPeninsulaRest/resources/prevProgPeninsula?callback=angular.callbacks._1&curva=DEMANDA&fecha=2013-01-01

https://demanda.ree.es/WSvisionaMovilesPeninsulaRest/resources/demandaGeneracionPeninsula?callback=angular.callbacks._2&curva=DEMANDA&fecha=2013-01-01

https://demanda.ree.es/WSvisionaMovilesPeninsulaRest/resources/coeficientesCO2?callback=angular.callbacks._3&curva=DEMANDA&fecha=2013-01-01

Use the "fecha" parameter to set the date. It seems it is not possible to get the whole year at once so you should iterate the calls to that link and change "fecha" to 2013-01-02, 2013-01-03, etc. for each month.

Sign up to request clarification or add additional context in comments.

Comments

1

Muchas gracias @miguel-febres! It now works more or less*. Where did you find the links from? :)

  • It runs some 10-20 loops and returns an address error, upon which I just start the macro again and it works... strange.

Sub Macro1() Application.DisplayAlerts = False

Do
    Workbooks.OpenText Filename:="https://demanda.ree.es/WSvisionaMovilesPeninsulaRest/resources/demandaGeneracionPeninsula?callback=angular.callbacks._2&curva=DEMANDA&fecha=" & ActiveCell.Value & ""
    Range(Selection, Selection.End(xlToRight)).Select
    Selection.Copy
    Windows("Spain").Activate
    ActiveCell.Offset(1, 0).Range("A1").Select
    Selection.PasteSpecial Paste:=xlPasteAll, Operation:=xlNone, SkipBlanks:= _
    False, Transpose:=True

    'close table
    Windows("demandaGeneracionPeninsula").Activate
    ActiveWindow.Close
    ActiveCell.Offset(-1, 1).Activate
Loop Until ActiveCell.Value = ""

End Sub

Now I just have to parse the results.. :)

1 Comment

I found the links using the Network tab in Chrome DevTools window. If you get an address error after a while it could be that too many consecutive requests are made to the server. Try using a delay between requests.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.