How can I format unknown filename with urlread?

1 view (last 30 days)
Hi all.
I must retrieve .txt file from a url like this:
but I don't succeed in using urlread, because the number between 'vadar_' and '_m0' is generating in real time (after a cgi query reported on web toolbar). How can I use a format mode for any unknown number in urlread?
Regards.

Accepted Answer

Walter Roberson
Walter Roberson on 17 Apr 2013
If you are getting it from a query then you can probably get it as a string. Then you can form the URL name as
['http://vadar.wishartlab.com/tmp/vadar_' NUMBERSTRING '_m0.stats.txt']
  4 Comments
Geggio®
Geggio® on 17 Apr 2013
I'd like this solution, but QueryID isn't known: it's generating from a web server program and I would retrive relative url with NUMBERSTRING. I post some code rows:
url = 'http://vadar.wishartlab.com/cgi-bin/vadarmulti.cgi?pdbid=4HHBA&statsinfo=1';
[stat, h1] = web(url);
First row is the query, then I open Matlab web browser, that generates a new urlread without the NUMBERSTRING. NUMBERSTRING is in a other window ('STATISTICS' on site), with a url
'http://vadar.wishartlab.com/tmp/vadar_'NUMBERSTRING'_m0.stats.txt'
that I can't retrieve without knowing it. (NUMBERSTRING is in the cgi source code...) It seems a maze, but I know it's my fault!
Regards.
Walter Roberson
Walter Roberson on 17 Apr 2013
The HTML generated by the site includes
<A HREF=/tmp/vadar_1366211367_m0.stats.txt target=_blank>Statistics</A>
You can parse this out of the string "stat" using regexp
relurl = regexp( stat, '(?<=HREF=)(\S+)(?=\s\S+Statistics)', 'match');
url = [ 'http://vadar.wishartlab.com' relurl{1} ];
urlread(url)

Sign in to comment.

More Answers (0)

Categories

Find more on Debugging and Analysis in Help Center and File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!