Created
December 28, 2015 16:36
-
-
Save licensed/dceca2cf4b28a25afc59 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from bs4 import BeautifulSoup | |
import urllib2 | |
print "O arquivo de saida estara no mesmo diretorio da aplicacao e tera o nome eventos.xls \n" | |
mes = raw_input("Digite o mes em numeral: ") | |
ano = '2015' | |
f = open('eventos' + mes + '.xls', 'w') | |
for dia in range(1,32): | |
dia = str(dia) | |
link = "http://www.cecon.pe.gov.br/eventos/?data-tipo=dia&data_inicial=" + dia + "%2F" + mes + "%2F" + ano | |
p = urllib2.urlopen(link) | |
conteudo = BeautifulSoup(p.read()) | |
ev = conteudo.findAll('span', attrs={'class' : 'evento-nome'}) | |
for evento in ev: | |
f.write(dia + '/' + mes + '/' + ano + '\t' + evento.string.encode('utf-8') + '\n') | |
f.close() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment