项目作者: stanimirivanovde

项目描述 :
Helps find cheap flights
高级语言: Java
项目地址: git://github.com/stanimirivanovde/flight-search.git
创建时间: 2020-08-19T14:46:53Z
项目社区:https://github.com/stanimirivanovde/flight-search

开源协议:

下载


Flight Search

Helps find cheap flights across multiple flight search engines

Introduction

Flight search was born out of my frustration of how cumborsome flight search is. You have to do many mouse clicks to set up your airports and dates of travel. And more clicks to check closer airports and other dates. And then if you come back tomorrow you have to do all this clicking again. This project is an attempt to automate all the clicks and get you results in real time.

How it works

You define a json file with your flight information. The tool then performs all the necessary searches of flights based on the json file. You can just review the results and pick the best flight. Once you have your json file generated you don’t need to do anything but run it. This way you can get results at any time. No more clicking with the mouse.

Primary purpose

Save on clicking. This tool eliminates all clicking to find a flight. Just define a simple json and run it as many times as you want to search for flights.

Secondary purpose

Find the cheapest possible combination of airports and dates for your trip. Around me I have 4 airports I can use: PHL, EWR, BWI and IAD. Lets say I’m also flexible with my dates: I can depart on Aug 9, 10 or 11 and get back on Sep 9, 10 or 11. Now lets say I’m travelling to Bulgaria which has two airports too: VAR and SOF. Ok, how many combinations exist between all airports and travel dates? What is the chaepest combination? This tool can answer this question. Without any annoying clicking of the mouse.

flightsearch usage

There are two projects here. First is the flight search project that you can find in the flightsearch/ directory
You can look at the help by supplying the -h argument to run.sh:

  1. usage: FlightSearch
  2. -f,--file <FILE> The JSON file that contains your
  3. search configuration.
  4. -g,--generate-urls Generate the URLs only without
  5. executing them.
  6. -h,--help Print this message.
  7. -n,--passangers <NUMBER OF PASSANGERS> The number of passangers to
  8. search for. The default is 1.
  9. -p,--paginate <NUMBER OF PAGES> The number of pages in a page.
  10. When that number of pages has
  11. been opened the user will be
  12. prompted to press enter in order
  13. to continue with the next page.
  14. The default number is 50 pages.
  15. -s,--site <SITE> The site you want to search.
  16. Currently supported sites are:
  17. Kayak, Google, Momondo, Hipmunk,
  18. FlightHub.
  19. -t,--sleep-time <TIME TO SLEEP> The number of seconds to sleep
  20. between each opened URL in
  21. miliseconds. The default is 800
  22. miliseconds.

Define a JSON file for your flight. Lets call it test.json Here is an example:

  1. [
  2. {
  3. "depart": {
  4. "origins": [
  5. "EWR",
  6. "PHL",
  7. "BWI",
  8. "IAD"
  9. ],
  10. "destinations": [
  11. "MUC"
  12. ],
  13. "dates": [
  14. {
  15. "day": 21,
  16. "month": 12,
  17. "year": 2019
  18. }
  19. ]
  20. },
  21. "returning": {
  22. "origins": [
  23. "VIE"
  24. ],
  25. "destinations": [
  26. "PHL",
  27. "EWR",
  28. "BWI",
  29. "IAD"
  30. ],
  31. "dates": [
  32. {
  33. "day": 26,
  34. "month": 1,
  35. "year": 2020
  36. }
  37. ]
  38. }
  39. }
  40. ]

Now lets run our permutation algorithm to see how many combinations exist:

  1. ./run.sh -g -f src/main/resources/test-2020.json -s momondo
  2. > Task :flightsearch:run
  3. Trip:
  4. TravelInfo:
  5. [EWR, PHL]
  6. [MUC]
  7. [FlightDate: 2019-12-21, FlightDate: 2019-12-22]
  8. TravelInfo:
  9. [VIE]
  10. [PHL, EWR]
  11. [FlightDate: 2020-01-26, FlightDate: 2020-01-27]
  12. Number of total Multi City URLs: 16
  13. Generated the URL: http://www.momondo.com/flightsearch/?Search=true&TripType=4&SegNo=2&SO0=EWR&SD0=MUC&SDP0=21-12-2019&SO1=VIE&SD1=PHL&SDP1=26-01-2020&AD=1&TK=ECO&DO=false&NA=false#Search=true&TripType=4&SegNo=2&SO0=EWR&SD0=MUC&SDP0=21-12-2019&SO1=VIE&SD1=PHL&SDP1=26-01-2020&AD=1&TK=ECO&DO=false&NA=false
  14. Generated the URL: http://www.momondo.com/flightsearch/?Search=true&TripType=4&SegNo=2&SO0=EWR&SD0=MUC&SDP0=21-12-2019&SO1=VIE&SD1=PHL&SDP1=27-01-2020&AD=1&TK=ECO&DO=false&NA=false#Search=true&TripType=4&SegNo=2&SO0=EWR&SD0=MUC&SDP0=21-12-2019&SO1=VIE&SD1=PHL&SDP1=27-01-2020&AD=1&TK=ECO&DO=false&NA=false
  15. Generated the URL: http://www.momondo.com/flightsearch/?Search=true&TripType=4&SegNo=2&SO0=EWR&SD0=MUC&SDP0=21-12-2019&SO1=VIE&SD1=EWR&SDP1=26-01-2020&AD=1&TK=ECO&DO=false&NA=false#Search=true&TripType=4&SegNo=2&SO0=EWR&SD0=MUC&SDP0=21-12-2019&SO1=VIE&SD1=EWR&SDP1=26-01-2020&AD=1&TK=ECO&DO=false&NA=false
  16. Generated the URL: http://www.momondo.com/flightsearch/?Search=true&TripType=4&SegNo=2&SO0=EWR&SD0=MUC&SDP0=21-12-2019&SO1=VIE&SD1=EWR&SDP1=27-01-2020&AD=1&TK=ECO&DO=false&NA=false#Search=true&TripType=4&SegNo=2&SO0=EWR&SD0=MUC&SDP0=21-12-2019&SO1=VIE&SD1=EWR&SDP1=27-01-2020&AD=1&TK=ECO&DO=false&NA=false
  17. Generated the URL: http://www.momondo.com/flightsearch/?Search=true&TripType=4&SegNo=2&SO0=EWR&SD0=MUC&SDP0=22-12-2019&SO1=VIE&SD1=PHL&SDP1=26-01-2020&AD=1&TK=ECO&DO=false&NA=false#Search=true&TripType=4&SegNo=2&SO0=EWR&SD0=MUC&SDP0=22-12-2019&SO1=VIE&SD1=PHL&SDP1=26-01-2020&AD=1&TK=ECO&DO=false&NA=false
  18. Generated the URL: http://www.momondo.com/flightsearch/?Search=true&TripType=4&SegNo=2&SO0=EWR&SD0=MUC&SDP0=22-12-2019&SO1=VIE&SD1=PHL&SDP1=27-01-2020&AD=1&TK=ECO&DO=false&NA=false#Search=true&TripType=4&SegNo=2&SO0=EWR&SD0=MUC&SDP0=22-12-2019&SO1=VIE&SD1=PHL&SDP1=27-01-2020&AD=1&TK=ECO&DO=false&NA=false
  19. Generated the URL: http://www.momondo.com/flightsearch/?Search=true&TripType=4&SegNo=2&SO0=EWR&SD0=MUC&SDP0=22-12-2019&SO1=VIE&SD1=EWR&SDP1=26-01-2020&AD=1&TK=ECO&DO=false&NA=false#Search=true&TripType=4&SegNo=2&SO0=EWR&SD0=MUC&SDP0=22-12-2019&SO1=VIE&SD1=EWR&SDP1=26-01-2020&AD=1&TK=ECO&DO=false&NA=false
  20. Generated the URL: http://www.momondo.com/flightsearch/?Search=true&TripType=4&SegNo=2&SO0=EWR&SD0=MUC&SDP0=22-12-2019&SO1=VIE&SD1=EWR&SDP1=27-01-2020&AD=1&TK=ECO&DO=false&NA=false#Search=true&TripType=4&SegNo=2&SO0=EWR&SD0=MUC&SDP0=22-12-2019&SO1=VIE&SD1=EWR&SDP1=27-01-2020&AD=1&TK=ECO&DO=false&NA=false
  21. Generated the URL: http://www.momondo.com/flightsearch/?Search=true&TripType=4&SegNo=2&SO0=PHL&SD0=MUC&SDP0=21-12-2019&SO1=VIE&SD1=PHL&SDP1=26-01-2020&AD=1&TK=ECO&DO=false&NA=false#Search=true&TripType=4&SegNo=2&SO0=PHL&SD0=MUC&SDP0=21-12-2019&SO1=VIE&SD1=PHL&SDP1=26-01-2020&AD=1&TK=ECO&DO=false&NA=false
  22. Generated the URL: http://www.momondo.com/flightsearch/?Search=true&TripType=4&SegNo=2&SO0=PHL&SD0=MUC&SDP0=21-12-2019&SO1=VIE&SD1=PHL&SDP1=27-01-2020&AD=1&TK=ECO&DO=false&NA=false#Search=true&TripType=4&SegNo=2&SO0=PHL&SD0=MUC&SDP0=21-12-2019&SO1=VIE&SD1=PHL&SDP1=27-01-2020&AD=1&TK=ECO&DO=false&NA=false
  23. Generated the URL: http://www.momondo.com/flightsearch/?Search=true&TripType=4&SegNo=2&SO0=PHL&SD0=MUC&SDP0=21-12-2019&SO1=VIE&SD1=EWR&SDP1=26-01-2020&AD=1&TK=ECO&DO=false&NA=false#Search=true&TripType=4&SegNo=2&SO0=PHL&SD0=MUC&SDP0=21-12-2019&SO1=VIE&SD1=EWR&SDP1=26-01-2020&AD=1&TK=ECO&DO=false&NA=false
  24. Generated the URL: http://www.momondo.com/flightsearch/?Search=true&TripType=4&SegNo=2&SO0=PHL&SD0=MUC&SDP0=21-12-2019&SO1=VIE&SD1=EWR&SDP1=27-01-2020&AD=1&TK=ECO&DO=false&NA=false#Search=true&TripType=4&SegNo=2&SO0=PHL&SD0=MUC&SDP0=21-12-2019&SO1=VIE&SD1=EWR&SDP1=27-01-2020&AD=1&TK=ECO&DO=false&NA=false
  25. Generated the URL: http://www.momondo.com/flightsearch/?Search=true&TripType=4&SegNo=2&SO0=PHL&SD0=MUC&SDP0=22-12-2019&SO1=VIE&SD1=PHL&SDP1=26-01-2020&AD=1&TK=ECO&DO=false&NA=false#Search=true&TripType=4&SegNo=2&SO0=PHL&SD0=MUC&SDP0=22-12-2019&SO1=VIE&SD1=PHL&SDP1=26-01-2020&AD=1&TK=ECO&DO=false&NA=false
  26. Generated the URL: http://www.momondo.com/flightsearch/?Search=true&TripType=4&SegNo=2&SO0=PHL&SD0=MUC&SDP0=22-12-2019&SO1=VIE&SD1=PHL&SDP1=27-01-2020&AD=1&TK=ECO&DO=false&NA=false#Search=true&TripType=4&SegNo=2&SO0=PHL&SD0=MUC&SDP0=22-12-2019&SO1=VIE&SD1=PHL&SDP1=27-01-2020&AD=1&TK=ECO&DO=false&NA=false
  27. Generated the URL: http://www.momondo.com/flightsearch/?Search=true&TripType=4&SegNo=2&SO0=PHL&SD0=MUC&SDP0=22-12-2019&SO1=VIE&SD1=EWR&SDP1=26-01-2020&AD=1&TK=ECO&DO=false&NA=false#Search=true&TripType=4&SegNo=2&SO0=PHL&SD0=MUC&SDP0=22-12-2019&SO1=VIE&SD1=EWR&SDP1=26-01-2020&AD=1&TK=ECO&DO=false&NA=false
  28. Generated the URL: http://www.momondo.com/flightsearch/?Search=true&TripType=4&SegNo=2&SO0=PHL&SD0=MUC&SDP0=22-12-2019&SO1=VIE&SD1=EWR&SDP1=27-01-2020&AD=1&TK=ECO&DO=false&NA=false#Search=true&TripType=4&SegNo=2&SO0=PHL&SD0=MUC&SDP0=22-12-2019&SO1=VIE&SD1=EWR&SDP1=27-01-2020&AD=1&TK=ECO&DO=false&NA=false

We see that we generated 16 permutations. The website we used is momondo.com. We generated 16 URLs that basically setup the appropriate combination for searching. In order to actually run the searches you can just remove the -g option and the default browser on your operating system will run all of the searches.

  1. ./run.sh -f src/main/resources/test-2020.json -s momondo

At this point you’re done. You just did 16 flight searches with all of your important combinations and you didn’t have to click a mouse once. Go through the results in your browser and find the best flight.

jsongenerator usage

The jsongenerator project creates complex json files based on specific criteria. It was born out of my idea to be able to perform very abstract searches for flights such as:

  • what is the cheapest weekend to fly in the next 3 months to Chicago
  • what is the cheapest 3 day weekend in the next 3 months to Los Angeles
  • what is the cheapest 4 day weekend in the next 6 months to New York

The jsongenerator project will use a sliding window technique that will always use the weekend and potentially add a day or two to it in order to extend the weekend. This way you can travel using minimum vacation days and find the cheapest weekend to hit the road.

In order to use it you’ll need to go into the jsongenerator/ directory.

  1. usage: JsonGenerator
  2. -a,--arrival-airport <AIRPORT> Arrival airport.
  3. -d,--depart-airport <AIRPORT> The airport for departure.
  4. -e,--end-date <DATE> The end date to stop the generation.
  5. Format is: YYYY-MM-DD
  6. -f,--first-weekday <WEEKDAY> The first weekday of the trip. Valid
  7. values are Mon, Tue, Wed, Thu, Fri,
  8. Sat, Sun.
  9. -h,--help Print this message.
  10. -l,--last-weekday <WEEKDAY> The end weekday of the trip. Valid
  11. values are Mon, Tue, Wed, Thu, Fri,
  12. Sat, Sun. This weekday can wrap as in
  13. first day Thu, last day Mon.
  14. -m,--move-value <VALUE> The number of days to generate a
  15. moving window. For each move value a
  16. new Trip will be generated with the
  17. first and last days incremented by
  18. one. Allowed values is 1 to 6.
  19. Default is 1
  20. -p,--number-of-passangers <COUNT> The number of passangers.
  21. -s,--start-date <DATE> The date to start generation. Format
  22. is: YYYY-MM-DD
  23. -w,--write-filename <NAME> The filename to use to save the
  24. generated JSON objects. The default
  25. filename is:
  26. depart_airport-arrival_airport-start_
  27. date-end_date.json

For example this command will generate all flights from IAD to BOS from date 2016-5-1 to 2016-7-1 from THU to SUN of every week using a 3 day moving window for 2 passangers. The moving window will move the dates from THU-SUN to FRI-MON and SAT-TUE.

  1. ./run.sh -d IAD -a BOS -s 2016-5-1 -e 2016-7-1 -f THU -l SUN -m 3 -p 2
  2. ...
  3. Number of trips generated: 27

The number of trips that we generated are 27. This means that we ca supply this json file to flightsearch and it will perform our 27 searches for us. Without clicking a button on the mouse.