我正在尝试从以下网站提取数据并导出到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格式,但我想以表格格式。表的第一部分
Libor Rates (USD) Latest Wk ago High Low
Libor Overnight 0.68889 0.69278 0.69544 0.3657
Libor 1 Week 0.72206 0.71944 0.72428 0.3866
Libor 1 Month 0.77111 0.76778 0.77667 0.425
Libor 2 Month 0.84694 0.83667 0.85111 0.5128
Libor 3 Month 1.03789 1.02372 1.04344 0.6126
Libor 6 Month 1.35239 1.33294 1.35822 0.85785
Libor 1 Year 1.72122 1.70178 1.73289 1.1156