Downlaoding data from a webpage

I want to save the data shown on USGS webpage: USGS data using Matlab. I am using MatLab 2014a; therefore, I have to use 'urlwrite' function. When I use it, I get the HTML content, not the data in txt format. Any suggestions on how do I download the data that is available on the link? I used the following code:
url='https://waterdata.usgs.gov/nwis/dv?cb_00060=on&format=rdb&site_no=03347000&referred_module=sw&period=&begin_date=1931-01-01&end_date=2018-01-26/';
filename='demo.txt';
outfilename = urlwrite(url,filename);

4 comentarios

Rik
Rik el 27 de En. de 2018
What is your exact code? I tested it on R2017b with urlwrite, and I got the txt file as expected.
Abhinav
Abhinav el 27 de En. de 2018
I have edited the question to include the code.
Rik
Rik el 27 de En. de 2018
I tested this code on R2012b and I'm getting an error with the https ("Error downloading URL. Your network connection may be down or your proxy settings improperly configured."), and the html you describe when I switch to http.
Have you tried saving a capture to the Wayback Machine? That sometimes solve http/https errors for me. You can try out this FEX submission.
Abhinav
Abhinav el 27 de En. de 2018
Okay, I will try to work it out using your suggestion. Thanks!

Iniciar sesión para comentar.

 Respuesta aceptada

Walter Roberson
Walter Roberson el 28 de En. de 2018

0 votos

Remove the trailing '/' in your URL.

Más respuestas (0)

Etiquetas

Preguntada:

el 27 de En. de 2018

Comentada:

el 28 de En. de 2018

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by