How can I get the last-modified time with python3 urllib?
Posted
by
Daenyth
on Stack Overflow
See other posts from Stack Overflow
or by Daenyth
Published on 2011-02-16T21:05:24Z
Indexed on
2011/02/18
7:25 UTC
Read the original article
Hit count: 248
I'm porting over a program of mine from python2 to python3, and I'm hitting the following error: AttributeError: 'HTTPMessage' object has no attribute 'getdate'
Here's the code:
conn = urllib.request.urlopen(fileslist, timeout=30)
last_modified = conn.info().getdate('last-modified')
This section worked under python 2.7, and so far I haven't been able to find out the correct method to get this information in python 3.1.
The full context is an update method. It pulls new files from a server down to its local database, but only if the file on the server is newer than the local file. If there's a smarter way to achieve this functionality than just comparing local and remote file timestamps, then I'm open to that as well.
© Stack Overflow or respective owner