Guest User

Untitled

a guest
Jan 23rd, 2019
103
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.93 KB | None | 0 0
  1. data = requests.get('https://www.infobolsa.es/acciones/ibex35')
  2.  
  3. soup = BeautifulSoup(data.text, 'html.parser')
  4.  
  5. print("")
  6. print("Aquí tienes los valores actuales del IBEX 35 a tiempo real")
  7. print("")
  8.  
  9. tabla = soup.find('table', {'class': 'fullTable' })
  10. tbody = tabla.find('tbody')
  11.  
  12. t = PrettyTable(['Nombre', 'Precio', 'Dif', 'Máximo', 'Mínimo', 'Renta', 'Volumen', 'Efectivo', 'Hora'])
  13.  
  14. for tr in tbody.find_all('tr'):
  15. nombre = tr.find_all('td')[2].text.strip()
  16. precio = tr.find_all('td')[3].text.strip()
  17. dif = tr.find_all('td')[4].text.strip()
  18. maximo = tr.find_all('td')[5].text.strip()
  19. minimo = tr.find_all('td')[6].text.strip()
  20. renta = tr.find_all('td')[7].text.strip()
  21. volumen = tr.find_all('td')[8].text.strip()
  22. efectivo = tr.find_all('td')[9].text.strip()
  23. hora = tr.find_all('td')[10].text.strip()
  24.  
  25. t.add_row([nombre, precio, dif, maximo, minimo, renta, volumen, efectivo, hora])
  26. print (t)
Add Comment
Please, Sign In to add comment