Advertisement
Rnery

Consumindo api simples..

Feb 17th, 2022 (edited)
1,114
1
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.55 KB | None | 1 0
  1. #!/usr/bin/env python3
  2. # -*- coding: utf-8 -*-
  3.  
  4. from re import compile
  5.  
  6. from bs4 import BeautifulSoup
  7. from requests import get
  8.  
  9. url = 'https://coinmarketcap.com/pt-br/currencies/coinracer/'
  10. headers = {'User-Agent': 'Mozilla/5.0 ()'}
  11.  
  12. requesicao = get(url, headers).text
  13.  
  14. # O soup é o padrão da lib
  15. soup = BeautifulSoup(requesicao, 'lxml')
  16.  
  17. # primeira forma
  18. # filtro = soup.find_all(class_=compile('priceValue'))
  19.  
  20. # Segunda forma
  21. filtro = soup.find_all('div', attrs={'class': 'priceValue'})
  22.  
  23. for span in filtro:
  24.     print(span.string)
  25.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement