?
Solved

find create and last modified date of web page

Posted on 2011-10-31
8
Medium Priority
?
783 Views
Last Modified: 2013-12-17
Hi

In a windows application .net c# I'm looking to find both the create and last modified date of a website page.

Any help please.
rgds
stephen
0
Comment
Question by:stephenwilde
  • 4
  • 4
8 Comments
 
LVL 9

Expert Comment

by:djon2003
ID: 37060752
Using the FileInfo class on the specific file you get use :
FileInfo fi = new FileInfo(filePath);
Date lastModifiedDate = fi.LastWriteTime;

Open in new window


http://msdn.microsoft.com/en-US/library/system.io.fileinfo_members(v=VS.80).aspx 
0
 

Author Comment

by:stephenwilde
ID: 37061007
Thanks

Will that work for a web page e.g. http://www.experts-exchange.com/aboutus.php?

Plus what about the original creation date?

Rgds
stephen  
0
 
LVL 9

Expert Comment

by:djon2003
ID: 37061019
You were talking about external sites ? Not yours ?
0
Get your Conversational Ransomware Defense e‑book

This e-book gives you an insight into the ransomware threat and reviews the fundamentals of top-notch ransomware preparedness and recovery. To help you protect yourself and your organization. The initial infection may be inevitable, so the best protection is to be fully prepared.

 

Author Comment

by:stephenwilde
ID: 37061125
Yes other websites, to monitior how often updates are performed.

This will be run from a Windows .net c# application on a looped thread.

Rgds
stephen
0
 
LVL 9

Expert Comment

by:djon2003
ID: 37061396
Now, you have to read into the http response headers to see if the header Last-Modified exists and then you will get the date.
Imports System
Imports System.IO
Imports System.Net
Module Module1
    Sub Main()
        'Address of URL
        Dim URL As String = "http://www.internic.com"
        Dim request As HttpWebRequest = WebRequest.Create(URL)
        Dim response As HttpWebResponse = request.GetResponse()
        Console.WriteLine(response.GetResponseHeader("Last-Modified"))
        Console.ReadLine()

    End Sub
End Module

Open in new window

This code is written in VB, though really simple to translate.

The site in the code works. Though, testing with google.com and yahoo.com doesn't give me anything.
0
 

Author Comment

by:stephenwilde
ID: 37088911
Thanks for a solutiuon

But are there any other ideas out there that would give a better success rate?
0
 
LVL 9

Accepted Solution

by:
djon2003 earned 2000 total points
ID: 37123050
I am quiet sure you won't find. The reason is simple: this information is only known by a website owner. So each owner can decide if they share with you this information or not.

Though, a solution could merely work. Downloading the page a first time which you associate today's date. After then, on periodic spot, you download the page again and compare if it has changed. If so, you change the associated date.
This method would only works (with whole compare between files) with static pages. Dynamic pages have to be think differently. A possible way would be to get the HTML once the page is loaded. Though, would you want to consider an ad change as a "real" page change. Probably not. So then, you shall have inspect the page to compare only parts which a relevant to page modification. I think, as you see, that it's starting to be quiet difficult and a long labor.
0
 

Author Closing Comment

by:stephenwilde
ID: 37123805
Thank you - sometimes code cannot provide the solution!
0

Featured Post

Granular recovery for Microsoft Exchange

With Veeam Explorer for Microsoft Exchange you can choose the Exchange Servers and restore points you’re interested in, and Veeam Explorer will present the contents of those mailbox stores for browsing, searching and exporting.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I found this questions asking how to do this in many different forums, so I will describe here how to implement a solution using PHP and AJAX. The logical flow for the problem should be: Write an event handler for the first drop down box to get …
Introduction Since I wrote the original article about Handling Date and Time in PHP and MySQL several years ago, it seemed like now was a good time to update it for object-oriented PHP.  This article does that, replacing as much as possible the pr…
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
The viewer will the learn the benefit of plain text editors and code an HTML5 based template for use in further tutorials.
Suggested Courses

840 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question