0

I am trying to pull data from below site and export into excel. I tried to pull data but i am getting more than what i want and i cant able to save into excel that data.

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()

getting in HTML format but i want in table format. First part of the table

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
Jeremy V.
  • 95
  • 10
  • Be more specific in your question so people can help you. Give an example of the expected output, and an example of the input you are pulling. – Ofer Arial Jan 26 '17 at 11:45
  • 1
    This happens because you are requesting an html page. The operation you want to do, commonly is done submitting a "GET" to an API Provider. (someone that gives to you a JSON with the LIbOR informations) but often those are under payed licence – Stefano Jan 26 '17 at 12:03
  • What you are trying to do is known as 'web scraping'. It's a bit risky as HTML is a visual descriptive format and not good at structuring data. This might help: http://stackoverflow.com/questions/18966368/python-beautifulsoup-scrape-tables – dodell Jan 26 '17 at 13:06
  • Try this. It finds the pattern of HTML structure and export to Excel. http://www.listly.io/ – Changmin Choi Apr 12 '17 at 12:42

0 Answers0