Reputation: 891
I want to do the following:
requestor = UrlRequestor("http://www.myurl.com/question?timestamp=", {'Content-Type': 'application/x-www-form-urlencoded', 'Cookie' : self.EASW_KEY + ";", 'X-UT-SID' :self.XUT_SID}, 'answer=' + self.securityHash)
requestor.open()
self.FUTPHISHING = requestor.getHeader('Set-Cookie').split(';')[0]
Right after timestamp, I would like to have the local time in this format: 1355002344943
How can I do this?
Upvotes: 0
Views: 501
Reputation: 104712
That timestamp looks to be based off of Unix time (e.g. seconds since Jan 1 1970), but it has three more digits. Probably it is in milliseconds, not seconds. To replicate it, I suggest doing:
import time
timestamp = int(time.time()*1000)
url = "http://www.myurl.com/question?timestamp=%d" % timestamp
You could also simply concatenate the timestamp onto the URL, if you don't want to do string formatting:
url = "http://www.myurl.com/question?timestamp=" + str(timestamp)
Upvotes: 1
Reputation: 462
You can get the time in that format from the time module. Specifically I'd do it this way
import time
timeurl = "http://www.myurl.com/question?timestamp=%s" % time.time()
requestor = UrlRequestor(timeurl, {'Content-Type': 'application/x-www-form-urlencoded', 'Cookie' : self.EASW_KEY + ";", 'X-UT-SID' :self.XUT_SID}, 'answer=' + self.securityHash)
requestor.open()
self.FUTPHISHING = requestor.getHeader('Set-Cookie').split(';')[0]
time.time() returns a float, so if it doesn't like that level of precision you can do
timeurl = "http://www.myurl.com/question?timestamp=%s" % int(time.time())
Upvotes: 1