@@ -0,0 +1,1459 @@
+#!env python3%0A# -*- coding: utf-8 -*-%0A%0Aimport logging%0Aimport sys%0Aimport requests%0Aimport os.path%0A%0Alogging.basicConfig(filename='history.log', level=logging.DEBUG,%0A                    format='%25(asctime)s:%25(levelname)s:%25(message)s'%0A                   )%0A%0ABASE_YEAR = 2016%0A%0Adef main():%0A    '''Retrieve some data from http://www.fuvest.br'''%0A%0A    range_years = int(sys.argv%5B1%5D) if len(sys.argv) %3E 1 else 10%0A    years = list(range(BASE_YEAR, BASE_YEAR - range_years, -1))%0A    logging.debug('Trying to get data of the last %25d years', range_years)%0A%0A    for year in years:%0A        url = 'http://www.fuvest.br/vest%7B0%7D/download/FUVEST_%7B0%7D_qase_inscr_car_fuvest_%7B0%7D.pdf'.format(year)%0A        logging.debug('Request year: %25d to server', year)%0A%0A        filename = url.split('/')%5B-1%5D%0A        if os.path.isfile(filename):%0A            logging.debug('Skiping this, file already exists')%0A            continue%0A%0A        try:%0A            data = requests.get(url, stream=True)%0A        except FileNotFoundError as e:%0A            logging.debug('Fails because of %25s', e)%0A        else:%0A            logging.debug('Done!')%0A%0A        logging.debug('Saving data on file %25s', filename)%0A        try:%0A            f = open(filename, 'wb')%0A            f.write(data.content)%0A            f.close()%0A        except IOError as e:%0A            logging.debug('Fails because of %25s', e)%0A        else:%0A            logging.debug('Done!')%0A%0A    logging.debug('Finished')%0A%0A%0Aif __name__ == '__main__':%0A    main()%0A

Add script to download pdf from web