Skip to content

Instantly share code, notes, and snippets.

@gabriel19913
Created January 31, 2019 20:10
Show Gist options
  • Select an option

  • Save gabriel19913/e3bb8cca9be0b2382778f3fa79f87bac to your computer and use it in GitHub Desktop.

Select an option

Save gabriel19913/e3bb8cca9be0b2382778f3fa79f87bac to your computer and use it in GitHub Desktop.
rom selenium import webdriver
from bs4 import BeautifulSoup
import csv
browser = webdriver.Chrome('C:\\Users\\100pau\\workspace\\chromedriver.exe')
browser.get('https://www.centauro.com.br/capacete-peels-mirage-storm-preto-e-verde-fosco-m00w4e-mktp.html?cor=34')
html = browser.execute_script("return document.getElementsByTagName('html')[0].innerHTML")
soup = BeautifulSoup(html, 'html.parser')
price = soup.select("._1y15b3k")
for item in price:
res = item
#seller = soup.select("._fynjto")[0].get_text()
#title = soup.select("._10o19jm")[0].get_text()
print(res)
#print(price[0])
#print(seller)
#print(title)
'''
final_list = [title, seller, price]
file_exists = os.path.isfile('centauro.csv')
with open(f'centauro.csv', 'a', newline='', encoding='latin1') as f:
header = ['Título', 'Vendedor', 'Preço']
writer = csv.DictWriter(f, fieldnames=header, delimiter=';')
if not file_exists:
writer.writeheader()
writer.writerows(final_list)'''
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment