Reading data from a different URL each iteration
2 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Salma fathi
el 18 de Oct. de 2022
Comentada: Salma fathi
el 24 de Oct. de 2022
i am trying to read some data from a specific website, in this website there are some parametrs that we need to set to get the desired data, now reading the data for manually speccifed parametrs is an easy job. Now I am trying to automate this proceess such that the parametrs would be changed accordingly and the data for each set of parameters would be read directly without my interaction. to do that I have the follwoing URL that I am reading the data from
httpUrl = "https://lgdc.uml.edu/common/DIDBGetValues?ursiCode=JI91J&charName=foF2,foF1,foE,foEs,hmF2,hmF1,hmE" + ...
"&DMUF=3000&fromDate=1997%2F01%2F01+00%3A00%3A00&toDate=1997%2F12%2F31+11%3A59%3A00";
where the parameters that need to be changed in the URL every time are the following
fromDate=1997%2F01%2F01+00%3A00%3A00 % where we need to change the year eveery time which is here =1997
which represent the starting date of the desired data and
toDate=1997%2F12%2F31+11%3A59%3A00 % where we need to change the year eveery time which is here =1997
which represent the ending date of the desired data. I strated with the follwoing lines but I am not sure how I can make the URL change every time and store all the read data in a table at the end.
httpUrl = "https://lgdc.uml.edu/common/DIDBGetValues?ursiCode=JI91J&charName=foF2,foF1,foE,foEs,hmF2,hmF1,hmE" + ...
"&DMUF=3000&fromDate=1997%2F01%2F01+00%3A00%3A00&toDate=1997%2F12%2F31+11%3A59%3A00";
options = weboptions("ContentType", "text");
data = webread(httpUrl, options);
Iono= array2table(data);
0 comentarios
Respuesta aceptada
Jan
el 18 de Oct. de 2022
Editada: Jan
el 18 de Oct. de 2022
F = "https://lgdc.uml.edu/common/DIDBGetValues?ursiCode=JI91J&charName=foF2,foF1,foE,foEs,hmF2,hmF1,hmE" + ...
"&DMUF=3000&fromDate=%04d%%2F01%%2F01+00%%3A00%%3A00&toDate=%04d%%2F12%%2F31+11%%3A59%%3A00";
% % -> %%, then 1997 -> %04d
URL = sprintf(F, 1998, 1999)
3 comentarios
Jan
el 24 de Oct. de 2022
F = "https://lgdc.uml.edu/common/DIDBGetValues?ursiCode=%s&charName=foF2,foF1,foE,foEs,hmF2,hmF1,hmE" + ...
"&DMUF=3000&fromDate=%04d%%2F01%%2F01+00%%3A00%%3A00&toDate=%04d%%2F12%%2F31+11%%3A59%%3A00";
URL = sprintf(F, 'QQQQQQ', 1998, 1999)
The format %04d prints a number with 4 digits and leading zeros. %s inserts a string or CHAR vector.
You find an exhaustive explanation of the formats at:
doc sprintf
Más respuestas (0)
Ver también
Categorías
Más información sobre Environment and Settings en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!