Html BeautifulSoup中的句柄o:p标签
我从以下方面提取了一些疾病信息: 但是数据包含在一个我不知道如何处理的标签中 我发现的一种方法是使用find_all函数,但是有没有任何方法可以作为tr.td.span.[o:p或其他什么]Html BeautifulSoup中的句柄o:p标签,html,beautifulsoup,Html,Beautifulsoup,我从以下方面提取了一些疾病信息: 但是数据包含在一个我不知道如何处理的标签中 我发现的一种方法是使用find_all函数,但是有没有任何方法可以作为tr.td.span.[o:p或其他什么] <td width="584" nowrap="" valign="top" style="width:438.0pt;padding:0in 5.4pt 0in 5.4pt; height:12.75pt"> <p class="MsoNormal"><span s
<td width="584" nowrap="" valign="top" style="width:438.0pt;padding:0in 5.4pt 0in 5.4pt;
height:12.75pt">
<p class="MsoNormal"><span style="font-size:10.0pt;font-family:"Arial","sans-serif"">UMLS:C0008031_pain
chest
<o:p>&nsp</o:p>
</span>
</p>
</td>
UMLS:C0008031\u
胸部
&nsp
输出:
如果你想要满满一桌的话,那是以防万一
但是你的要求
使用:
将熊猫作为pd导入
df=pd.read\u html(
"http://people.dbmi.columbia.edu/~friedma/Projects/diseasesemploy/kb/index.html“[0]
打印(df[2][1:][.values.tolist())
对于bs4
使用
导入请求
从bs4导入BeautifulSoup
r=requests.get(
"http://people.dbmi.columbia.edu/~friedma/Projects/diseaseshipmentKB/index.html”)
soup=BeautifulSoup(r.text'html.parser')
对于soup.findAll(“p”,{'class':'MsoNormal'})中的项:
item=item.get_文本(strip=True)
如果项目启动时带有(“UMLS”):
打印(项目)
我试图了解您想要提取的内容以及问题所在,但我还无法达到要点@aԋ625; 1213; aԃmєιcαη我需要知道o:p标记中的内容检查下面我的答案
import pandas as pd
df = pd.read_html(
"http://people.dbmi.columbia.edu/~friedma/Projects/DiseaseSymptomKB/index.html")[0]
df.to_csv("out.csv", index=False, header=False)