我试图提取页面上document.write
函数内的帧标记的属性,如下所示:
<script language="javascript">
.
.
.
document.write('<frame name="nav" src="/nav/index_nav.html" marginwidth="0" marginheight="0" scrolling="no" frameborder="0" border = "no" noresize>');
if (anchor != "") {
document.write('<frame name="body" src="http://content.members.fidelity.com/mfl/summary/0,,' + cusip + ',00.html?' + anchor + '" marginwidth="0" marginheight="0" scrolling="auto" frameborder="0" noresize>');
} else {
document.write('<frame name="body" src="http://content.members.fidelity.com/mfl/summary/0,,' + cusip + ',00.html" marginwidth="0" marginheight="0" scrolling="auto" frameborder="0" noresize>');
}
document.write('</frameset>');
// end hiding -->
</script>
findAll('frame')
方法没有帮助。有没有办法读取帧标签的内容?在
我使用的是python2.5和beautifulsoup3.0.8。在
我也愿意在BeautifulSoup3.1中使用Python3.1 只要我能得到结果。在
谢谢
Pyparsing可以帮助您在JS和HTML的混合中架起桥梁。此解析器查找包含一个带引号的字符串或多个带引号的字符串和标识符的字符串表达式的
document.write
语句,准计算字符串表达式,分析它以查找嵌入的<frame>
标记,并将frame属性作为pyparsing ParseResults对象返回,这使您可以访问命名属性,就像它们是对象属性或dict键(您的首选项)。在印刷品:
^{pr2}$你不能光靠美女组合。beauthoulsoup解析HTML就像它到达浏览器时一样(在任何重写或DOM操作之前),它不解析(更不用说执行)Javascript。在
在这种特殊情况下,您可能需要使用一个简单的正则表达式。在
相关问题 更多 >
编程相关推荐