【发布时间】:2019-05-10 18:11:04
【问题描述】:
我有一个带有 CDATA 标记的 HTML 源代码,其中包含我想要的一些信息。
当我尝试以下操作时:
switch_url = switch_soup.find_all(text=re.compile(('Switches')))
我得到这个输出:
['//<![CDATA[\n "url":"https://xxxx.meraki.com/xxxxxxx/n/xxxxx/manage/nodes/list","name":"Switches","admin_only":false},{"is_current":false,"url":"https://nxx.meraki.com/xxxxx/n/xxxxx/manage/configure/switchports","name":"Switch ports","admin_only":false},{"is_current":false,"url":"https://xxxx.meraki.com/Dormitory/n/xxxxxxx/manage/configure/dhcp_servers"//]]>\n ']
如何从 CDATA 输出中获取“Switches”网址,即:“https://xxxx.meraki.com/xxxxxxx/n/xxxxx/manage/nodes/list”?
提前致谢!
【问题讨论】:
标签: python beautifulsoup cdata