Extract hyperlink from data retrieved through urlread()
6 views (last 30 days)
Show older comments
Graeme MacKenzie
on 14 Jun 2016
Commented: Graeme MacKenzie
on 20 Jun 2016
I am trying to extract urls listed on a website using urlread. urlread gives me the page's content and regexprep allows me to isolate the content I'm interested in (shown in the command window) but I can't seem to extract the url contained in the hyperlink. urlread apparently doesn't return hyperlinks and yet when I hover over the hyperlink in the command window I can find the address I'm looking for (highlighted in yellow in the lower left corner of the image). Any way to extract the url in the hyperlink?
0 Comments
Accepted Answer
Julian
on 17 Jun 2016
By default hyperlinks are rendered in the command window. You already have the underlying text that you want in your variable but you have to hover over the hyperlink to see it in the command window. The variable editor will show the underlying HTML. So you should easily be able to extract the URLs with something like
hyperlinks = regexp(html,'<a.*?/a>','match');
I have often though that it would be really useful to have something like "Copy Link Address" available on a right click in the command window (particularly to extract matlab: hyperlinks).. What do you think?
More Answers (0)
See Also
Categories
Find more on Get Started with MATLAB in Help Center and File Exchange
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!