Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- data = requests.get('https://www.infobolsa.es/acciones/ibex35')
- soup = BeautifulSoup(data.text, 'html.parser')
- print("")
- print("Aquí tienes los valores actuales del IBEX 35 a tiempo real")
- print("")
- tabla = soup.find('table', {'class': 'fullTable' })
- tbody = tabla.find('tbody')
- t = PrettyTable(['Nombre', 'Precio', 'Dif', 'Máximo', 'Mínimo', 'Renta', 'Volumen', 'Efectivo', 'Hora'])
- for tr in tbody.find_all('tr'):
- nombre = tr.find_all('td')[2].text.strip()
- precio = tr.find_all('td')[3].text.strip()
- dif = tr.find_all('td')[4].text.strip()
- maximo = tr.find_all('td')[5].text.strip()
- minimo = tr.find_all('td')[6].text.strip()
- renta = tr.find_all('td')[7].text.strip()
- volumen = tr.find_all('td')[8].text.strip()
- efectivo = tr.find_all('td')[9].text.strip()
- hora = tr.find_all('td')[10].text.strip()
- t.add_row([nombre, precio, dif, maximo, minimo, renta, volumen, efectivo, hora])
- print (t)
Add Comment
Please, Sign In to add comment