473,748 Members | 2,602 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

finding time when url was modified

hi!

i am reading a file on the Web. How can i find out when it was last
modified?

thanks


----------------------------------------------------------------
This message was sent using IMP, the Internet Messaging Program.
Jul 18 '05 #1
6 1923
Ajay wrote:
hi!

i am reading a file on the Web. How can i find out when it was last
modified?

thanks

That would be the "Last-Modified" HTTP header, when it's present.

Python 2.3.4 (#1, Jun 13 2004, 11:21:03)
[GCC 3.3.1 (cygming special)] on cygwin
Type "help", "copyright" , "credits" or "license" for more information.
from urllib import urlopen
f = urlopen("http://www.holdenweb.c om/")
print f.headers

Server: Microsoft-IIS/5.0
Date: Tue, 28 Sep 2004 01:50:38 GMT
Content-Type: text/html
Accept-Ranges: bytes
Last-Modified: Wed, 25 Aug 2004 17:47:51 GMT
ETag: "242599a4cb8ac4 1:f460"
Content-Length: 12456

Oops, time I reinstalled the auto-update code to keep my Python links fresh!

regards
Steve
Jul 18 '05 #2
Quoting Steve Holden <st***@holdenwe b.com>:
Ajay wrote:
hi!

i am reading a file on the Web. How can i find out when it was last
modified?

thanks
That would be the "Last-Modified" HTTP header, when it's present.

Python 2.3.4 (#1, Jun 13 2004, 11:21:03)
[GCC 3.3.1 (cygming special)] on cygwin
Type "help", "copyright" , "credits" or "license" for more information.
>>> from urllib import urlopen
>>> f = urlopen("http://www.holdenweb.c om/")
>>> print f.headers

Server: Microsoft-IIS/5.0
Date: Tue, 28 Sep 2004 01:50:38 GMT
Content-Type: text/html
Accept-Ranges: bytes
Last-Modified: Wed, 25 Aug 2004 17:47:51 GMT
ETag: "242599a4cb8ac4 1:f460"
Content-Length: 12456

Oops, time I reinstalled the auto-update code to keep my Python links
fresh!


is it possible for someone to change the Last-Modified header? Can someone
put a new updated document, but in such a way that if someone requests
that document, they get an old date rather than the new date?
i can see a CGI script add its own header and then write out the document.
but can this be done with a simple HTML page?

thanks


regards
Steve
--
http://mail.python.org/mailman/listinfo/python-list

----------------------------------------------------------------
This message was sent using IMP, the Internet Messaging Program.
Jul 18 '05 #3
Ajay wrote:
is it possible for someone to change the Last-Modified header? Can someone
put a new updated document, but in such a way that if someone requests
that document, they get an old date rather than the new date?
i can see a CGI script add its own header and then write out the document.
but can this be done with a simple HTML page?


Certainly... the server can do anything it wants with that
header, including failing to provide it, providing an invalid
date, providing a date in the future or distant past, or
even providing a date that happens to correspond exactly
with the true "last modified" date of the document...

Whether a *particular* server will do that with a *particular*
kind of document is a different question altogether.

Do you have a specific situation involving this that you
can describe, or are you just asking in general, out of
curiosity?

-Peter
Jul 18 '05 #4
Quoting Peter Hansen <pe***@engcorp. com>:
Ajay wrote:
is it possible for someone to change the Last-Modified header? Can someone
put a new updated document, but in such a way that if someone requests
that document, they get an old date rather than the new date?
i can see a CGI script add its own header and then write out the

document.
but can this be done with a simple HTML page?


Certainly... the server can do anything it wants with that
header, including failing to provide it, providing an invalid
date, providing a date in the future or distant past, or
even providing a date that happens to correspond exactly
with the true "last modified" date of the document...

Whether a *particular* server will do that with a *particular*
kind of document is a different question altogether.

Do you have a specific situation involving this that you
can describe, or are you just asking in general, out of
curiosity?


thanks
it was mostly out of curiousity. I have an interchange where the servers
would send a policy and request a resource. the other server would
evaluate the policy and respond accordingly.
i am hoping to cut down on the evaluation by maintaining a record of past
transactions and if everything is the same (policy, resource ets) then
take the same action as before. one way was to store policy used earlier
and compare that with the new one and so on. since the app is for a mobile
device with low processing power, i was hoping to perhaps use modified date
- which when i thought a little more about it is clearly not feasible.

i guess comparing two really large strings is what i'll have to go with.
any ideas on performance of string comparisons?

cheers

-Peter
--
http://mail.python.org/mailman/listinfo/python-list

----------------------------------------------------------------
This message was sent using IMP, the Internet Messaging Program.
Jul 18 '05 #5
Ajay wrote:
Quoting Peter Hansen <pe***@engcorp. com>:

Ajay wrote:
is it possible for someone to change the Last-Modified header? Can


someone
put a new updated document, but in such a way that if someone requests
that document, they get an old date rather than the new date?
i can see a CGI script add its own header and then write out the


document.
but can this be done with a simple HTML page?


Certainly.. . the server can do anything it wants with that
header, including failing to provide it, providing an invalid
date, providing a date in the future or distant past, or
even providing a date that happens to correspond exactly
with the true "last modified" date of the document...

Whether a *particular* server will do that with a *particular*
kind of document is a different question altogether.

Do you have a specific situation involving this that you
can describe, or are you just asking in general, out of
curiosity?

thanks
it was mostly out of curiousity. I have an interchange where the servers
would send a policy and request a resource. the other server would
evaluate the policy and respond accordingly.
i am hoping to cut down on the evaluation by maintaining a record of past
transactions and if everything is the same (policy, resource ets) then
take the same action as before. one way was to store policy used earlier
and compare that with the new one and so on. since the app is for a mobile
device with low processing power, i was hoping to perhaps use modified date
- which when i thought a little more about it is clearly not feasible.

i guess comparing two really large strings is what i'll have to go with.
any ideas on performance of string comparisons?

Compare the MD5 checksums instead. Python has an MD5 function, somewhere ...

regards
Steve
Jul 18 '05 #6
On Tue, 28 Sep 2004 12:57:45 +1000, Ajay wrote:
thanks
it was mostly out of curiousity. I have an interchange where the servers
would send a policy and request a resource. the other server would
evaluate the policy and respond accordingly.


I would recommend going a little more deeply into the HTTP standards, and
then examining what the capabilities of your servers are. I have no
experience with mobile devices.

In particular, take a look at the E-Tags field; if you have support for
it, that will pretty much do exactly what you want with nearly no work on
your part if I am reading your requirements correctly; all you have to do
is catch the HTTP result code and do the right thing with it.

A shocking number of people re-implement large chunks of HTTP in the HTML,
which is painful and often ineffective. HTTP is pretty cool, if you use it
to the full and not just as a glorified file, ignoring the headers.

Jul 18 '05 #7

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

13
15254
by: yaipa | last post by:
What would be the common sense way of finding a binary pattern in a ..bin file, say some 200 bytes, and replacing it with an updated pattern of the same length at the same offset? Also, the pattern can occur on any byte boundary in the file, so chunking through the code at 16 bytes a frame maybe a problem. The file itself isn't so large, maybe 32 kbytes is all and the need for speed is not so great, but the need for accuracy in the...
2
13195
by: Robizzle | last post by:
Sorry, I must be blind but I can't seem to find it anywhere. What function will return the time a file was created? I see filemtime(...) returns the time that file was last Modified and fileatime(...) returns the time that a file was last accessed but what about created? Tried php.net and google, nothing =(
3
6033
by: mosdef_underground | last post by:
How can I use C# to find the most recently modified file in a folder? As you can probably guess, I am just a beginner, so any help would be appreciated. Thanks!
1
2552
by: Francesc Guim Bernat | last post by:
Dear colleagues, i'm getting in troubles using one XML library with Visual Studio .NET and Xerces with Xalan. When i execute the code i get the next run time error: "Run-Time Check Failure #2 - Stack around the variable 'resolver' was corrupted." Looking on internet i've seen that the compiler, if you're running your
3
1861
by: Joe Kimbler | last post by:
I'm writing a "Hot Directory" software package that watches for an MP3 file to be uploaded to an FTP directory. When the file has completed uploading, it will be converted into a WAV file and imported into an automation system. The problem that I am having is telling if IIS (FTP) is done uploading the file and it is no longer in use. Currently, the software just checks the file time. If the time is older than 5 minutes, the software...
1
1687
by: Simon Forman | last post by:
I've got a function that I'd like to improve. It takes a list of lists and a "target" element, and it returns the set of the items in the lists that appear either before or after the target item. (Actually, it's a generator, and I use the set class outside of it to collect the unique items, but you get the idea. ;-) ) data = , , ,
1
1434
by: abhi.10dulkar | last post by:
Hi guys, This might be simplest thing, but I am newbie to databases. I need to find out only rows modified within certain time period from a database. As I undertand a way out could be adding an where clause for the time period might be an option, I might be wrong here again. But, wanted to know is there any other option. Can triggers or any other things help me in this matter.
9
17028
by: Hemant Shah | last post by:
How do I find out when the table was modified? When I look at syscat.tables it only lists creation time. -- Hemant Shah /"\ ASCII ribbon campaign E-mail: NoJunkMailshah@xnet.com \ / --------------------- X against HTML mail TO REPLY, REMOVE NoJunkMail / \ and postings
275
12345
by: Astley Le Jasper | last post by:
Sorry for the numpty question ... How do you find the reference name of an object? So if i have this bob = modulename.objectname() how do i find that the name is 'bob'
0
9530
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9363
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
9238
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8237
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6793
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6073
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4864
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3300
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
2206
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.