gpt4 book ai didi

html - 使用MATLAB解析HTML中 anchor 中的URL,帮助快速

转载 作者:太空宇宙 更新时间:2023-11-04 15:33:39 25 4
gpt4 key购买 nike

我有严格的时间限制,我真的需要一个正则表达式来解析这种类型的 anchor (它们都是这种格式)

<a href="20120620_0512_c2_1024.jpg">20120620_0512_c2_102..&gt;</a>

网址

20120620_0512_c2_1024.jpg

我知道它不是完整的 URL,它是相对的,请帮忙

到目前为止,这是我的代码

year = datestr(now,'yyyy');
timestamp = datestr(now,'yyyymmdd');
html = urlread(['http://sohowww.nascom.nasa.gov//data/REPROCESSING/Completed/' year '/c2/' timestamp '/']);
links = regexprep(html, '<a href=.*?>', '');

最佳答案

尝试以下操作:

url = 'http://sohowww.nascom.nasa.gov/data/REPROCESSING/Completed/2012/c2/20120620/';
html = urlread(url);
t = regexp(html, '<a href="([^"]*\.jpg)">', 'tokens');
t = [t{:}]'

生成的元胞数组(截断):

t = 
'20120620_0512_c2_1024.jpg'
'20120620_0512_c2_512.jpg'
...
'20120620_2200_c2_1024.jpg'
'20120620_2200_c2_512.jpg'

关于html - 使用MATLAB解析HTML中 anchor 中的URL,帮助快速,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11126721/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com