You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This is more a request than a issue itself, the support for python still lacks some small things compared to atom, things like functions and some texts are not highlighted as it should.
Here's the code, its just a simple web scrapper so nothing really important here
from selenium import webdriver
from selenium.webdriver.common.keys import Keys
from bs4 import BeautifulSoup
import pandas
import time
url = "https://www.amazon.com/"
#* abre o browser
browser = webdriver.Firefox()
browser.implicitly_wait(30)
#* abre o url
browser.get(url)
search_bar = browser.find_element_by_id("twotabsearchtextbox") # acha a search bar
search_bar.clear()
#* pesquisa na search bar
search_bar.send_keys("computer")
search_bar.submit()
#* espera um pouco a pagina carregar
time.sleep(10)
# pega o html da pagina
content = browser.page_source
soup = BeautifulSoup(content, "html.parser")
#* fecha o browser
browser.quit()
products = []
prices = []
ratings = []
#* procura em todas as classes de um produto e pega seus atributos
for product in soup.find_all(class_="a-section a-spacing-medium"):
# pega classe com o nome
name = product.find(class_="a-size-medium a-color-base a-text-normal")
# pega classe com o preco
price = product.find(class_="a-price-whole")
# pega classe com avaliacao
rating = product.find(class_="a-icon-alt")
# caso nao tiver nome ignorar
if name != None:
products.append(name.text)
prices.append(price.text)
ratings.append(rating.text)
#* cria um dataframe
df = pandas.DataFrame({
"Product Name": products,
"Price": prices,
"Rating": ratings
})
#* joga o dataframe para um csv
df.to_csv("produtos.csv", index=False, encoding="utf-8")
Here's the screenshot of the code in atom
Here's the screenshot of the same code in vscode
VSCode version: 1.37.1
Theme version: 2.1.0
I'm using the python extensions for this, most precisely the MagicPython extension, and it's a python 3.7 code.
The text was updated successfully, but these errors were encountered:
This is more a request than a issue itself, the support for python still lacks some small things compared to atom, things like functions and some texts are not highlighted as it should.
Here's the code, its just a simple web scrapper so nothing really important here
Here's the screenshot of the code in atom
Here's the screenshot of the same code in vscode
I'm using the python extensions for this, most precisely the MagicPython extension, and it's a python 3.7 code.
The text was updated successfully, but these errors were encountered: