def crawl(): logging.basicConfig() logging.getLogger().setLevel(logging.INFO) parser = argparse.ArgumentParser() parser.add_argument( "begin", help="Date for the beginning of search in format YYYY-MM-DD", type=isoformat_date) parser.add_argument("end", help="Date for the end of search in format YYYY-MM-DD", type=isoformat_date) parser.add_argument("origin", help="3 letter code for the origin airport", type=str) parser.add_argument("destination", help="3 letter code for the destination airport", type=str) cli_args = parser.parse_args() bot = crawler.Crawler() bot.crawl_wrapper(cli_args.begin, cli_args.end, origin=cli_args.origin, destination=cli_args.destination)
def main(): logging.basicConfig() logging.getLogger().setLevel(logging.INFO) airports, days = parse_arguments() bot = crawler.Crawler() bot.crawl( days, destination=airports[0], origin=airports[1], )
def main(): argv = utils.return_sys_argv() howmany = int(argv[1]) variant = int(argv[2]) bot = crawler.Crawler() flights = bot.import_from_redis() stations = import_stations() weekends = bot.weekend_organizer(flights, variant=variant) print(f"Variant {variant}") print( tabulate.tabulate(table(weekends, stations)[:howmany], tablefmt="psql"))
def test_request(): """Full bot test with mocked response.""" responses.add( responses.GET, "https://desktopapps.ryanair.com/v4/en-ie/availability", json=testutils.open_json_fixture("response.json"), ) results = crawler.Crawler().crawl( datetime.datetime.fromisoformat("2020-02-15"), datetime.datetime.fromisoformat("2020-02-16"), "BCN", "SXF") assert results == { "2020-02-15BCNSXF06:35": 81.99, "2020-02-15BCNSXF16:25": 39.3, "2020-02-15SXFBCN09:45": 128.99, "2020-02-15SXFBCN13:15": 72.24, "2020-02-16BCNSXF06:35": 81.99, "2020-02-16BCNSXF16:25": 194.99, "2020-02-16SXFBCN09:45": 128.99, "2020-02-16SXFBCN13:15": 291.99, "2020-02-17BCNSXF06:35": 194.99, "2020-02-17BCNSXF16:25": 167.99, "2020-02-17SXFBCN09:45": 81.99, "2020-02-17SXFBCN13:15": 81.99, "2020-02-18BCNSXF16:25": 291.99, "2020-02-18SXFBCN13:15": 99.99, "2020-02-19BCNSXF16:25": 194.99, "2020-02-19SXFBCN13:15": 99.99, "2020-02-20BCNSXF16:25": 117.99, "2020-02-20SXFBCN13:15": 69.99, "2020-02-21BCNSXF06:35": 230.99, "2020-02-21BCNSXF16:25": 291.99, "2020-02-21SXFBCN09:45": 69.99, "2020-02-21SXFBCN13:15": 81.99, }
def bot(): return crawler.Crawler()