Coder Social home page Coder Social logo

southwest-search's Introduction

southwest-search

Author: Derek Redfern

License: MIT

Project Status - Abandoned

This project has unfortunately been broken for several years, and is unlikely to get any better. Please don't create new issues against it, but feel free to create a PR if you're able to get it working again :)

READ THIS FIRST

This script is currently mostly-broken due to some additions by SW to their API. Until it can be reverse-engineered, you'll need to do some manual steps for this to work. Screenshot to guide you is below.

  1. Open up your web browser's network console (F12 -> Network in chrome)
  2. Go to SW's website and make a legitimate search
  3. Look for the request that was made to https://www.southwest.com/api/air-booking/v1/air-booking/page/air/booking/shopping
  4. Look at the headers attached to that request. Copy and paste the ones that start with ee30zvqlwf (there should be 6 of them) into southwest.py at line 45. ee30zvqlwf-d and ee30zvqlwf-z likely don't need to be changed.
  5. You should be able to run this script for X days after following the above steps. I'm assuming the headers will eventually expire and you'll need to regenerate them, but I don't know what X is.

Header inspection

Description

This script is a rudimentary search engine for Southwest Airlines flights. I created it because I love flying Southwest SO MUCH, but the search functionality on their website is incredibly painful when you have flexible airports or flexible dates. Flying anywhere with more than 1 or 2 variables is a nightmare - you have to open multiple browser windows to southwest.com for each possible combination.

Give southwest.py a list of airports you're able to fly out of and into, a list of dates you can fly, and what you want to optimize for (cost, time, number of stops). It'll return all possible flights sorted by your chosen criteria! Maybe you want to fly from any of the 3 SF-area airports to any of the 3 NYC-area airports anytime during the week of Thanksgiving, for example. And you want to do it cheaply. You can search for all of those parameters and get the results compiled into one list.

Mission: Don't Anger Southwest

My goal here is to make it easier for you (and me) to fly Southwest without angering the Southwest Powers-That-Be. Southwest has previously taken down tools in this vein to protect their business model, which I respect and am trying not to disrupt. To that end:

  • I will not host this to be run interactively on the web, now or at any point in the future - you must download and run it yourself.
  • Be mindful that each variable you add increases the number of pages the script has to scrape on southwest.com. 3 departure airports, 3 arrival airports, and 3 dates is already a whopping 27 pages!
  • The script is rate-limited (1 request every 2 seconds) to reduce the stress on the servers, so large queries may take a while to complete. Run it in the background and go do something else for a bit.

Website updates

Any updates to the format of Southwest's API may cause very strange errors. Inputs are also not completely sanitized and may cause similar errors. If this is the case, open a Github issue and I'll try to bring it back to working order.

Contributing

Contributions are always welcome and appreciated. I try to stick to PEP8 where I can, with max line length of 100. If you make a change, take out a PR and include testing transcripts and I'll try to merge it in ASAP.

Installation and Usage

Requirements

You must have, at a minimum:

  • Python 2.7
  • Python modules from pip or another source:
    • tabulate (0.7.7+)
    • requests

Only tested on Linux, but there's no reason it shouldn't work on OS X or Windows (if you can manage to install the Python requirements on Windows)

Upgrade Note

The date format for the command line has changed as of September 16, 2018. Previously the date format for the command line was MM/DD/YYYY. The command line is now looking for dates in YYYY-MM-DD format.

Setting up and using the script on Linux

git clone https://github.com/redfern314/southwest-search.git
cd southwest-search
sudo pip install requests tabulate
python southwest.py -a ARRIVAL_CITIES -d DEPARTURE_CITIES -t DATES

Example Query

$ python southwest.py -d SFO -a LGA -t 2018-12-02 -s fares
Processed 1/1
flight     date        depart    arrive    fares                              route                               stops  duration
---------  ----------  --------  --------  ---------------------------------  --------------------------------  -------  ----------
4158/3971  2018-12-02  06:00     18:50     [u'139.80', u'586.58', u'614.58']  [u'SFO', u'DAL', u'LGA']                1  9:50
4158/4604  2018-12-02  06:00     16:55     [u'161.80', u'586.58', u'614.58']  [u'SFO', u'DAL', u'LGA']                1  7:55
4026/4503  2018-12-02  11:40     23:05     [u'196.80', u'586.58', u'614.58']  [u'SFO', u'STL', u'LGA']                1  8:25
2803/4491  2018-12-02  12:55     23:25     [u'323.80', u'586.58', u'614.58']  [u'SFO', u'DEN', u'LGA']                1  7:30
4324/3625  2018-12-02  09:15     22:25     [u'327.90', u'590.68', u'618.68']  [u'SFO', u'SAN', u'DAL', u'LGA']        2  10:10

southwest-search's People

Contributors

dredfern-zoox avatar jipis avatar raybb avatar redfern314 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

southwest-search's Issues

Sort by time ignores date field

Unfortunately, sorting by departure or arrival times, if searching across multiple dates, isn't useful. Times across two different dates are intermingled, sorted SOLELY by the time column. To wit:

$ python southwest.py -d BWI -a FLL -t 2018-12-29 2018-12-30 -m 0 -l -s depart -e toFLL
Processed 1/2
Processed 2/2
  flight  date        depart    arrive      fares  route               stops  duration
--------  ----------  --------  --------  -------  ----------------  -------  ----------
    3370  2018-12-29  06:15     08:55      278.98  [u'BWI', u'FLL']        0  02:40
     136  2018-12-30  06:20     09:00      213.98  [u'BWI', u'FLL']        0  02:40
    3988  2018-12-29  07:55     10:35      460.98  [u'BWI', u'FLL']        0  02:40
    6771  2018-12-30  08:50     11:35      298.98  [u'BWI', u'FLL']        0  02:45
    3937  2018-12-29  09:55     12:40      298.98  [u'BWI', u'FLL']        0  02:45
    3078  2018-12-29  10:50     13:30      298.98  [u'BWI', u'FLL']        0  02:40
    5980  2018-12-30  10:55     13:40      298.98  [u'BWI', u'FLL']        0  02:45
    4435  2018-12-30  13:00     15:40      298.98  [u'BWI', u'FLL']        0  02:40
    4481  2018-12-29  13:10     15:50      298.98  [u'BWI', u'FLL']        0  02:40
    5726  2018-12-30  15:25     18:05      298.98  [u'BWI', u'FLL']        0  02:40
    6722  2018-12-29  15:35     18:15      298.98  [u'BWI', u'FLL']        0  02:40
    5513  2018-12-30  16:40     19:20      298.98  [u'BWI', u'FLL']        0  02:40
    3094  2018-12-30  17:30     20:10      298.98  [u'BWI', u'FLL']        0  02:40
    5544  2018-12-29  17:35     20:15      298.98  [u'BWI', u'FLL']        0  02:40
    5462  2018-12-30  18:40     21:20      298.98  [u'BWI', u'FLL']        0  02:40
    3221  2018-12-29  19:10     21:50      213.98  [u'BWI', u'FLL']        0  02:40
    6818  2018-12-30  21:20     23:55      163.98  [u'BWI', u'FLL']        0  02:35
    3076  2018-12-29  21:50     00:25      163.98  [u'BWI', u'FLL']        0  02:35
    2617  2018-12-30  22:25     01:00      163.98  [u'BWI', u'FLL']        0  02:35

no form matching name 'buildItineraryForm'

It appears Southwest has changed their form layout. It seems that the form no longer even has a name element. In fact, the form page has completely changed location, even.

I attempted to fix it myself to at least lead you towards a solution, but my python is WAY rusty.

No results even though 'success'

Hey there, thanks for making this awesome tool. I really could use something like this for some places where Southwest has planes flying between two locations that require a layover they don't make routes for (like HNL to LGA).

Anyway, when I search I get empty results:

python southwest.py -a SFO -d LAX -t 2021-06-19
'success'
flight    depart    depart    arrive    fares    route    num      duration
num       date      time      time                        stops
--------  --------  --------  --------  -------  -------  -------  ----------

Any ideas? I updated the request headers as mentioned in readme.

empty

image
why empty?I've already replaced the ones that start with ee30zvqlwf.thanks!

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.