<p>使用XML/HTML解析器是处理XML/HTML文档/框架集的正确方法:</p>
<pre><code>from lxml import etree
from io import StringIO
data = [{'type': 'text/html', 'value': '<table> <tr><td> <a href="https://www.reddit.com/r/wallpapers/comments/6dhhhj/waving_bear/"> <img src="https://b.thumbs.redditmedia.com/v5CaHQ_S-m4L5MUfX2a6ViwZWe2yvft_VyG8Iol0CJs.jpg" alt="Waving bear" title="Waving bear" /> </a> </td><td> &#32; submitted by &#32; <a href="https://www.reddit.com/user/mexicanwave"> /u/mexicanwave </a> <br/> <span><a href="http://i.imgur.com/PMgfJSm.jpg">[link]</a></span> &#32; <span><a href="https://www.reddit.com/r/wallpapers/comments/6dhhhj/waving_bear/">[comments]</a></span> </td></tr></table>', 'base': 'https://www.reddit.com/r/wallpapers.rss', 'language': None}]
parser = etree.HTMLParser() # creating parser instance
html_data = etree.parse(StringIO(data[0]['value']), parser) # parser is fed with html data
url = [a.attrib['href'] for a in html_data.findall(".//a") if 'imgur.com' in a.attrib['href']]
print(url)
</code></pre>
<p>输出:</p>
<pre><code>['http://i.imgur.com/PMgfJSm.jpg']
</code></pre>
<p><a href="https://docs.python.org/3.6/library/xml.etree.elementtree.html" rel="nofollow noreferrer">https://docs.python.org/3.6/library/xml.etree.elementtree.html</a></p>