Skip to content

Parse the scan history on the package tracking page into Tracking #192

Open

Description

@acq3

Acknowledgements

  • I have written a descriptive issue title
  • This isn't about signing in, which amazon-auth handles
  • I have searched amazon-orders's documentation to see if the feature is already supported
  • I have searched Issues to see if the feature has already been requested
  • I have enabled debug mode and am attaching relevant console logs and HTML files

Summary

Tracking reads the carrier and tracking number from the package tracking page, but not the events on the same page (delivered, out for delivery, etc.). Thoughts on a Tracking.events list, so a caller can see when and where a package last moved without parsing the page a second time?

Describe the Enhancement

The carrier layout of the package tracking page lists its scans by day: under each .tracking-event-date-header ("Monday, January 5") follow rows with .tracking-event-time, .tracking-event-message and .tracking-event-location. progress-tracker-ups.html and progress-tracker-amazon.html already carry them.

Proposed:

  • Tracking.events: Optional[List[TrackingEvent]], newest first as the page lists them, read through safe_parse. None when the page shows no scan list (the status-only layout).
  • TrackingEvent(Parsable) with date (the day as the page writes it), time ("11:02 AM", or None on a row without one), message and location (None when blank).
  • Selectors beside FIELD_TRACKING_CARRIER_SELECTOR.

date stays text because the page gives no year: turning it into a date needs a reference day that parse_tracking doesn't take, and assuming today would make the same page parse differently depending on when it's read.

tracking = amazon_orders.get_tracking(shipment.tracking_link)
for event in tracking.events or []:
    print(event.date, event.time, event.message, event.location)

Tests would assert on the two existing fixtures, so no new resources are needed.

Happy to open a PR for your review if you think this makes sense!

Describe Alternative Solutions/Workarounds

Parsing the scan list outside the library, from the same HTML parse_tracking already reads. It works, but it is a second parser of one page that drifts from the library's selectors whenever Amazon changes the layout, and every caller that wants the history has to write it.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions