Python Web抓取研究摘要-在输出中维护要点的问题
我正在网上搜集各种研究摘要,并创建一个数据集。当我尝试为PCORI摘要这样做时,我能够得到我所需要的,但是当文本有要点时,要点:Python Web抓取研究摘要-在输出中维护要点的问题,python,pandas,text,web-scraping,beautifulsoup,Python,Pandas,Text,Web Scraping,Beautifulsoup,我正在网上搜集各种研究摘要,并创建一个数据集。当我尝试为PCORI摘要这样做时,我能够得到我所需要的,但是当文本有要点时,要点: 不在我的输出中,并且 与项目符号点关联的缩进也不相同 我是一个有点新手,虽然我确实到处寻找其他代码,但我惊讶地发现没有其他人有同样的问题。我正在使用的示例是: 问题是,无论何时使用.get_text(“”),都会去掉html。在本例中,它去掉了创建要点的和标记 import requests from bs4 import BeautifulSoup import r
问题是,无论何时使用
.get_text(“”
),都会去掉html。在本例中,它去掉了创建要点的
和
标记
import requests
from bs4 import BeautifulSoup
import re
import pandas as pd
out = []
urlsummary ='https://www.pcori.org/research-results/2013/testing-new-ways-
schedule-appointments-community-health-centers-help-patients'
html = requests.get(urlsummary).content
soup = BeautifulSoup(html, 'lxml')
abstract = soup.find(class_='pane pane--node').get_text(" ")
about = abstract.split('What was the research about?')[1]
project_status = soup.find(class_='field field-name-field-award-
status').get_text(" ")
data = {'About': about, 'abstract': abstract, 'Status': project_status}
out.append(data)
df = pd.DataFrame(out)
print (df)
df.to_excel('PCORI_Results.xlsx')