Created
November 22, 2017 07:00
-
-
Save bluetechy/dcaa5af71f4a2dc51f940469aa705621 to your computer and use it in GitHub Desktop.
Tracking Number Link Generator (UPS, FedEx, DHL)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import re | |
def tracking_link_html(tracking_number): | |
regex_handlers = [ | |
(r'\b(1Z ?[0-9A-Z]{3} ?[0-9A-Z]{3} ?[0-9A-Z]{2} ?[0-9A-Z]{4} ?[0-9A-Z]{3} ?[0-9A-Z]|[\dT]\d\d\d ?\d\d\d\d ?\d\d\d)\b', ups_link), | |
(r'(\b96\d{20}\b)|(\b\d{15}\b)|(\b\d{12}\b)', fedex_link), | |
(r'\b((98\d\d\d\d\d?\d\d\d\d|98\d\d) ?\d\d\d\d ?\d\d\d\d( ?\d\d\d)?)\b', fedex_link), | |
(r'^[0-9]{12}$', fedex_link), | |
(r'^[0-9]{10}$', dhl_link) | |
] | |
for regex, link_method in regex_handlers: | |
if re.match(regex, tracking_number): | |
return link_method() # return the link | |
return tracking_number # return the tracking number as a string | |
def fedex_link(tracking_number): | |
return '<a href="http://www.fedex.com/Tracking?tracknumbers=%(num)s&action=track&language=english" target="_blank">%(num)s</a>' % {'num': tracking_number} | |
def ups_link(tracking_number): | |
return '<a href="http://wwwapps.ups.com/WebTracking/processInputRequest?InquiryNumber1=%(num)s&sort_by=status&tracknums_displayed=1&TypeOfInquiryNumber=T&track.x=0&track.y=0" target="_blank">%(num)s</a>' % {'num': tracking_number} | |
def dhl_link(tracking_number): | |
return '<a href="http://www.dhl.com/content/g0/en/express/tracking.shtml?brand=DHL&AWB=%(num)s" target="_blank">%(num)s</a>' % {'num': tracking_number} |
how this will work ?
hello, yes please which project ?
…On Wed, Feb 17, 2021 at 5:35 AM alpakmaz ***@***.***> wrote:
***@***.**** commented on this gist.
------------------------------
how this will work ?
—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub
<https://gist.github.com/dcaa5af71f4a2dc51f940469aa705621#gistcomment-3633984>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AK4TIBXHAJGACYAX44XWPXTS7NIRBANCNFSM4TF2I4YQ>
.
looking for a tracking generator like video
https://www.youtube.com/watch?v=R-dYJ9LRUzM
hi i'm also looking for a same like this
https://www.youtube.com/watch?v=R-dYJ9LRUzM
hi i'm also looking for a same like this
https://www.youtube.com/watch?v=R-dYJ9LRUzM
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
fonctions don't return nothing ?