我尝试使用Python使用以下代码在PRE标记之间进行解析
s = br.open(base_url+str(string))
u = br.geturl()
seq = br.open(u)
blat = BeautifulSoup(seq)
for res in blat.find('pre').findChildren():
seq = res.string
print seq
来自以下HTML源代码:
^{pr2}$当我想解析最后一个元素时,它给出了第一个PRE-tag元素。如果有什么建议,我将不胜感激。 我希望输出如下:
00000001 taaaagatgaagtttctatcatccaaaaaatgggctacagaaacc 00000045
<<<<<<<< ||||||||||||||||||||||||||| |||||||||||||||| <<<<<<<<
41256227 taaaagatgaagtttctatcatccaaagtatgggctacagaaacc 41256183
而我现在的输出是
T
AAAAGATGA
AGTTTCTATC
ATCCAAA
A
TGGGCTACAG
AAAC
C
您可以使用^{} 获得最后的结果:
其中
index.html
包含您提供的html。在它打印:
^{pr2}$另一个选择是依赖前面的
h4
标记来获得适当的pre
:相关问题 更多 >
编程相关推荐