我想创建一个网页,其中所有图像居住在我的网站上列出的标题和替代表示。
我已经写了一个小程序来查找和加载所有的 HTML 文件,但现在我卡在如何提取 src
,title
和 alt
从这个 HTML:
<img src="/image/fluffybunny.jpg" title="Harvey the bunny" alt="a cute little fluffy bunny" />
I guess this should be done with some regex, but since the order of the tags may vary, and I need all of them, I don't really know how to parse this in an elegant way (I could do it the hard char by char way, but that's painful).