From 7b770e6072e595bddda94d75a3739359b2f61e9e Mon Sep 17 00:00:00 2001 From: Jon Bergli Heier Date: Tue, 14 Mar 2017 09:27:39 +0100 Subject: tracking: Changed user-agent for fedex requests. Apparently fedex is now blocking the default urllib2 user-agent, set our own user-agent to work around this. --- modules/tracking.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/modules/tracking.py b/modules/tracking.py index 2b0ddd7..957bf62 100755 --- a/modules/tracking.py +++ b/modules/tracking.py @@ -182,7 +182,8 @@ class FedexModule(TrackingModule): data = {'TrackPackagesRequest': {'appType': 'wtrk', 'uniqueKey': '', 'processingParameters': {'anonymousTransaction': True, 'clientId': 'WTRK', 'returnDetailedErrors': True, 'returnLocalizedDateTime': False}, 'trackingInfoList': [{'trackNumberInfo': {'trackingNumber': code, 'trackingQualifier': '', 'trackingCarrier': ''}}]}} url = 'https://www.fedex.com/trackingCal/track?' + urllib.urlencode({'data': json.dumps(data), 'action': 'trackpackages', 'locale': 'en_US', 'format': 'json', 'version': 99}) try: - u = urllib2.urlopen(url) + request = urllib2.Request(url, headers = {'User-Agent': 'fot'}) + u = urllib2.urlopen(request) except urllib2.HTTPError as e: raise PackageError(str(e)) data = u.read() -- cgit v1.2.3