Code Monkey home page Code Monkey logo

Comments (6)

nalvarez508 avatar nalvarez508 commented on June 19, 2024

Tested with curl -i -X POST -H 'Content-Type: application/json' -d <somedata> https://www.amtrak.com/v4/journey-solution-option may have to try with cookies or through a browser.
One thought is to get cookies from a chromedriver session and pass this in the post request
This returned the default "couldn't process your request" error from amtrak's site, same as when using an unmodified webdriver

from amtrak-rail-planner.

nalvarez508 avatar nalvarez508 commented on June 19, 2024

https://stackoverflow.com/questions/46361494/how-to-get-the-localstorage-with-python-and-selenium-webdriver

from amtrak-rail-planner.

nalvarez508 avatar nalvarez508 commented on June 19, 2024

Parsing session storage worked. Each train is stored in the following path:

journeySolutionOption : dict
  journeyLegs : list (of one dict)
    journeyLegOptions : list (of all results as dict)
      % data stored in here as a mix of list of lists and dicts

This not only makes parsing a page faster as we just need session storage, but it also reveals a lot of hidden data such as fare types and train information for multiple segments, seating accommodations, etc. Would need a deep dive.

from amtrak-rail-planner.

nalvarez508 avatar nalvarez508 commented on June 19, 2024

Useful keys from session storage.
searchresults is the meat of what we're after
stationsData_stations returns a list of every location served by amtrak, train or bus
traincodes returns every train by number. Train website is /firstword-secondword-train.
The latter two can be retrieved just by going to amtrak.com

from amtrak-rail-planner.

nalvarez508 avatar nalvarez508 commented on June 19, 2024

After closer examination:

  • traincodes is useful, but for what, I am not sure in this application
  • stationsData_stations is great and well formatted but includes bus stops which seems out of scope at this point. However I would not be opposed to including this feature later, perhaps as an "Include Bus Stops" option.
  • searchresults I really want to work but it still requires that we use a search, and with a webdriver, what's the point

from amtrak-rail-planner.

nalvarez508 avatar nalvarez508 commented on June 19, 2024

JSON data only

from amtrak-rail-planner.

Related Issues (14)

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.