Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

general: fix ups command #87

Open
jahschwa opened this issue Apr 15, 2021 · 0 comments
Open

general: fix ups command #87

jahschwa opened this issue Apr 15, 2021 · 0 comments

Comments

@jahschwa
Copy link
Owner

Working backend code:

import requests

URL_HOME = 'https://www.ups.com/track?loc=en_US&Requester=lasso/trackdetails'
URL_API = 'https://www.ups.com/track/api/Track/GetStatus?loc=en_US'

def track(track_id):
  """returns (status, eta, activity_list)"""

  s = requests.Session()
  s.get(URL_HOME)

  kwargs = {
    'headers': {
      'X-XSRF-TOKEN': s.cookies['X-XSRF-TOKEN-ST'],
    },
    'json': {
      'TrackingNumber': [track_id],
    },
  }

  data = s.post(URL_API, **kwargs).json()['trackDetails'][0]

  return (
    data['packageStatus'],
    data['scheduledDeliveryDate'],
    [x for x in data['shipmentProgressActivities'][::-1] if x['date'].strip()],
  )
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant