Try this:
(will scrape page and show all table elements)
you will need to install requests and lxml:
(will scrape page and show all table elements)
you will need to install requests and lxml:
pip install requests, lxml
import requests from bs4 import BeautifulSoup def parsepage(page): soup = BeautifulSoup(page, 'lxml') table = soup.find('table') if table is not None: trs = table.find_all('tr') for n, tr in enumerate(trs): tds = tr.find_all('td') for n1, td in enumerate(tds): print(f"\n------------------------------ tr_{n}, td_{n1} ------------------------------") print(f"{td.prettify}") else: print(f"Cound not find table") def scrape_url(url): response = requests.get(url) if response.status_code == 200: page = response.content parsepage(page) else: print(f"unable to retreive {url}") if __name__ == '__main__': url = 'https://www.global-rates.com/interest-rates/libor/libor.aspx' scrape_url(url)partial results:
Output:------------------------------ tr_0, td_0 ------------------------------
<bound method Tag.prettify of <td>
<table cellpadding="0" cellspacing="0" style="width:100%;margin:10px 0px 0px 0px;">
<tr>
<td>
<img alt="" src="//www.global-rates.com/images/misc/ittybittyclear.gif" style="margin:3px 4px 3px 0px;"/>
</td>
<td align="right" valign="bottom">
<a href="//www.global-rates.com/"><img alt="English - worldwide actual interest rates and economic indicators" border="0" src="//www.global-rates.com/images/misc/gb.gif"/></a>
<a href="//nl.global-rates.com/"><img alt="Nederlands - actuele, internationale rentetarieven en economische indicatoren" border="0" src="//www.global-rates.com/images/misc/nl.gif"/></a>
<a href="//de.global-rates.com/"><img alt="Deutsch - aktuelle, internationale Zinssätze und Wirtschaftindikatoren" border="0" src="//www.global-rates.com/images/misc/de.gif"/></a>
<a href="//es.global-rates.com/"><img alt="Español - Español - tipos de interés e indicadores económicos actuales e internacionales" border="0" src="//www.global-rates.com/images/misc/es.gif"/></a>
<a href="//it.global-rates.com/"><img alt="Italiano - tassi dâinteresse internazionali e sugli indicatori economici" border="0" src="//www.global-rates.com/images/misc/it.gif"/></a>
<a href="//fr.global-rates.com/"><img alt="Français - taux dâintérêts et indicateurs économiques actuelles et internationaux" border="0" src="//www.global-rates.com/images/misc/fr.gif"/></a>
<a href="//pt.global-rates.com/"><img alt="Português - taxas de juros actuais e internacionais e indicadores económicos" border="0" src="//www.global-rates.com/images/misc/pt.gif"/></a>
</td>
</tr>
</table>
</td>>
------------------------------ tr_0, td_1 ------------------------------
<bound method Tag.prettify of <td>
<img alt="" src="//www.global-rates.com/images/misc/ittybittyclear.gif" style="margin:3px 4px 3px 0px;"/>
</td>>