python中内置了很多html和xml库,很难相信不支持实际的HTML解析.
我已经为这个任务找到了很多很棒的第三方库,但是这个问题是关于python标准库的.
要求:
)Hello, <i>World</i>!
)奖励积分:
<big>does anyone here know <html ???
根据要求,这是我的90%解决方案.这适用于我尝试过的有限的HTML集,但正如每个人都可以清楚地看到的那样,这并不完全可靠.因为我通过盯着文档15分钟和一行代码来做到这一点,我想我可以咨询stackoverflow社区以获得类似但更好的解决方案......
from xml.etree.ElementTree import fromstring
DOM = fromstring("<html>%s</html>" % html.replace(' ', ' '))
Run Code Online (Sandbox Code Playgroud)