How to use baixar_arquivo method in SeleniumBase

Best Python code snippet using SeleniumBase

baixandoArquivoInternet.py

Source:baixandoArquivoInternet.py Github

copy

Full Screen

1import requests2import os3# link do conteudo https://pythoncafe.com.br/post/baixando-arquivos-da-internet/4# def baixar_arquivo(url, endereco):5# resposta = requests.get(url)6# if resposta.status_code == requests.codes.OK:7# with open(endereco, 'wb') as novo_arquivo:8# novo_arquivo.write(resposta.content)9# print("Download finalizado. Arquivo salvo em: {}".format(endereco))10# else:11# resposta.raise_for_status()12# melhorias para evitar erro13# def baixar_arquivo(url, endereco):14# resposta = requests.get(url, stream=True) #AQUI15# if resposta.status_code == requests.codes.OK:16# with open(endereco, 'wb') as novo_arquivo:17# for parte in resposta.iter_content(chunk_size=256): #AQUI TBM18# novo_arquivo.write(parte)19# print("Download finalizado. Arquivo salvo em: {}".format(endereco))20# else:21# resposta.raise_for_status()22def baixar_arquivo(url, endereco=None):23 if endereco is None:24 endereco = os.path.basename(url.split("?")[0])25 resposta = requests.get(url, stream=True)26 if resposta.status_code == requests.codes.OK:27 with open(endereco, 'wb') as novo_arquivo:28 for parte in resposta.iter_content(chunk_size=256):29 novo_arquivo.write(parte)30 print("Download finalizado. Arquivo salvo em: {}".format(endereco))31 else:32 resposta.raise_for_status()33if __name__ == "__main__":34 # testando a função35 test_url = "https://www.visgraf.impa.br/Data/RefBib/PS_PDF/wtd2018/adaptive-reconstruction-implicit-finalv1.pdf"...

Full Screen

Full Screen

baixar_arquivos.py

Source:baixar_arquivos.py Github

copy

Full Screen

1import zipfile2import requests3def baixar_arquivo(url, endereco):4 resposta = requests.get(url)5 if resposta.status_code== requests.codes.OK: 6 with open(endereco, 'wb') as novo_arquivo:7 novo_arquivo.write(resposta.content)8 print("Donwload Finalizado. Salvo em: {}".format(endereco))9 else:10 resposta.raise_for_status()11if __name__ == "__main__":12 baixar_arquivo('https://www.gov.br/ans/pt-br/arquivos/assuntos/consumidor/o-que-seu-plano-deve-cobrir/Anexo_I_Rol_2021RN_465.2021_RN473_RN478_RN480_RN513_RN536.pdf', 'Anexo 1.pdf')13 baixar_arquivo('https://www.gov.br/ans/pt-br/arquivos/assuntos/consumidor/o-que-seu-plano-deve-cobrir/Anexo_I_Rol_2021RN_465.2021_RN473_RN478_RN480_RN513_RN536.xlsx', 'Anexo 1.xlsx')14 baixar_arquivo('https://www.gov.br/ans/pt-br/arquivos/assuntos/consumidor/o-que-seu-plano-deve-cobrir/Anexo_II_DUT_2021_RN_465.2021_tea.br_RN473_RN477_RN478_RN480_RN513_RN536.pdf', 'Anexo 2.pdf')15 baixar_arquivo('https://www.gov.br/ans/pt-br/arquivos/assuntos/consumidor/o-que-seu-plano-deve-cobrir/Anexo_III_DC_2021_RN_465.2021.v2.pdf', 'Anexo 3.pdf')16 baixar_arquivo('https://www.gov.br/ans/pt-br/arquivos/assuntos/consumidor/o-que-seu-plano-deve-cobrir/Anexo_IV_PROUT_2021_RN_465.2021.v2.pdf', 'Anexo 4.pdf')17z = zipfile.ZipFile('Anexos.zip', 'w', zipfile.ZIP_DEFLATED)18z.write('Anexo 1.pdf')19z.write('Anexo 1.xlsx')20z.write('Anexo 2.pdf')21z.write('Anexo 3.pdf')22z.write('Anexo 4.pdf')...

Full Screen

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run SeleniumBase automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful