我需要从一个网站上获取信息,并在<font color="red">needed-info-here</font>OR 之间<span style="font-weight:bold;">needed-info-here</span>随机输出.
我用的时候可以拿到它
start = '<font color="red">'
end = '</font>'
expression = start + '(.*?)' + end
match = re.compile(expression).search(web_source_code)
needed_info = match.group(1)
Run Code Online (Sandbox Code Playgroud)
,但后来我要挑获取要么<font>或者<span>,失败,当网站所使用的其他标记.
如何修改正则表达式以使其始终成功?