Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import requests
- from bs4 import BeautifulSoup
- try:
- pesquisaProduto = str(input('Oque deseja pesquisar ?:'))
- requestMercadoLivre = requests.get('https://lista.mercadolivre.com.br/' + pesquisaProduto)
- responseMercadoLivre = BeautifulSoup(requestMercadoLivre.text,'html.parser')
- valoresProdutos = responseMercadoLivre.find_all(class_='price__fraction')
- nomeProdutos = responseMercadoLivre.find_all(class_='main-title')
- for nprodutos in nomeProdutos:
- format_nomes = str(nprodutos.text.strip())
- for valores in valoresProdutos:
- format_valores = str(valores.text.strip())
- print(format_nomes)
- print("R$:" + format_valores)
- except KeyboardInterrupt:
- print('Consulta interrompida')
Add Comment
Please, Sign In to add comment