从网站中提取数据并使用python导出到excel

2024-10-01 17:30:59 发布

您现在位置:Python中文网/ 问答频道 /正文

我试图从下面的网站拉数据和导出到excel。我试图拉数据,但我得到的比我想要的多,我不能保存到excel的数据。在

import requests
from BeautifulSoup import BeautifulSoup
url_libor = 'http://online.wsj.com/mdc/public/page/2_3020-libor.html'
response_libor = requests.get(url_libor)
html_libor = response_libor.content
soup1_libor = BeautifulSoup(html_libor)
table_libor = soup1_libor.find('table', attrs={'style': 'border-top:0px solid #CCCCCC;border-bottom:0px;'})
table_libor1 =  soup1_libor.find('div', attrs={'class': 'tableDesc'})
table_libor1.append(table_libor)
print table_libor1.prettify()

在HTML格式,但我想在表格格式。表的第一部分

^{pr2}$

Tags: 数据importurlresponsehtmltablefindrequests

热门问题