-2
Guys, can you help me please.
How can I replace the wd.get
for my code?
Edit:
Error presented
Code running on colab:
!pip install -q kora
!pip install -U plotly
!pip install yfinance --upgrade --no-cache-dir
import datetime
import numpy as np
import pandas as pd
import yfinance as yf
import pandas_datareader.data as web
from time import sleep
from kora.selenium import wd
def busca_carteira_teorica(indice, espera=8):
url = f'https://sistemaswebb3-listados.b3.com.br/indexPage/day/{indice.upper()}?language=pt-br'
wd.get(url)
sleep(espera)
wd.find_element_by_id('segment').send_keys("Setor de Atuação")
sleep(espera)
wd.find_element_by_link_text("Download").click()
sleep(espera)
arquivos = !ls -1t *.csv ##modificado com o modulo subprocess (import subprocess)
#arquivos = subprocess.Popen(['ls', '-lt', '*.csv'], stdout=subprocess.PIPE, stderr=subprocess.STDOUT) #funcionando no replit
return pd.read_csv(arquivos[0], sep=';', encoding='ISO-8859-1',skipfooter=2, engine='python', thousands='.', decimal=',', header=1, index_col=False)
dados_indice = busca_carteira_teorica('util')
print(dados_indice)
Why are you trying to use a colab module in repl.it? Use direct Selenium
– Augusto Vasques
@Augustovasques I made the change and updated the post, what I should do now, can help me please?
– Claudio
Is this your complete code? or is it reference to another third-party code ?
– stack.cardoso
With what I see. What I can help you with is telling you not to scrape data with Selenium. Use the module scrapy, Unlike Selenium he specializes in web Scrapping. But if you detail what you are doing you may be able to help you more.
– Augusto Vasques
@stack.Rdoso this is the main part, data scraping, the treatment I did not put
– Claudio
@Augustovasques my reference is this video https://youtu.be/b9bU_ryC5rc?t=390 but I intend to take it off the colab and put it in the repl.it I’m having this difficulty of scraping the data (I updated the code working on the colab)
– Claudio
wants this instruction to work on the physical pc
– stack.cardoso
@stack.Rdoso exactly.. but n wanted to download physical files
– Claudio