Beispiel #1
0
    parser.add_argument(
        '-e',
        '--enddate',
        type=int,
        default=time.strftime('%Y%m%d', time.localtime(time.time())),
        help='end date (YYYYMMDD), if not assigned, set as today')
    parser.add_argument(
        '-t',
        '--threads',
        type=int,
        default=multiprocessing.cpu_count(),
        help=
        'how many threads to use, if not assigned thread will be the same as cpu cores'
    )
    parser.add_argument('-p',
                        '--province',
                        help='the province to get, if not assigned crawl all')
    args = parser.parse_args()
    logger = init_logger()

    db = DBIO(args.database)
    ex = Exporter(db, args.threads, args.startdate, args.enddate)
    if args.province:
        ex.get_province(args.province)
    else:
        for prov in provinces:
            ex.get_province(prov)
    db.close()
    e_time = time.time()
    logger.info('Used %s seconds' % (e_time - s_time))