summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJon Bergli Heier <snakebite@jvnv.net>2017-03-14 09:27:39 +0100
committerJon Bergli Heier <snakebite@jvnv.net>2017-03-14 09:30:49 +0100
commit7b770e6072e595bddda94d75a3739359b2f61e9e (patch)
tree7e7c9e86a00e0f06a3c51651063df4547d21f090
parent301103b31e56c214572663893f233de41c3e1d56 (diff)
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.
-rwxr-xr-xmodules/tracking.py3
1 files changed, 2 insertions, 1 deletions
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()