Skip to content

Instantly share code, notes, and snippets.

@gabrielcesar
Created August 29, 2014 14:49
Show Gist options
  • Save gabrielcesar/52717109f067c3402915 to your computer and use it in GitHub Desktop.
Save gabrielcesar/52717109f067c3402915 to your computer and use it in GitHub Desktop.
Using wget over Python.
#!/usr/bin/env python
'''
20140829
Uso:
Na variavel file insira o arquivo a ser baixado com URL completa.
Lembrando que o sitio, `caixa.gov.br' faz controle de downloads por IP.
Espero ter colaborado.
[email protected]
'''
import os
accept = 'Accept: text/html'
user_agent = 'Mozilla/5.0 ( Macintosh; Intel Mac OS X 10.8; rv:21.0) Gecko/20100101 Firefox/21.0'
file = 'http://www1.caixa.gov.br/loterias/_arquivos/loterias/D_lotfac.zip'
command = 'wget -c --header="%s" --user-agent="%s" %s' % ( accept, user_agent, file )
os.system ( command )
@NicosKaralis
Copy link

Ainda tem como fazer este código funcionar? Toda forma q eu tento da erro 404

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment