Get the latest update time of the webpage

Source: Internet
Author: User

/**
* Get the webpage Update Time
* Enter the webpage URL
* Returns the webpage Update Time string.
*/
Private string getupdatetime (string strurl ){
String strtime = NULL;

Url hp;
Urlconnection hpcon = NULL;
Try {
HP = new URL (strurl );
Hpcon = hp. openconnection ();
} Catch (malformedurlexception e ){
// Todo automatically generates catch Blocks
E. printstacktrace ();
Return "error ";
} Catch (ioexception e ){
// Todo automatically generates catch Blocks
E. printstacktrace ();
Return "error ";
}

Date = new date (hpcon. getlastmodified ());
Long n = date. gettime ();

If (n = 0 ){
Return NULL;
}
Strtime = date. tostring ();
Return strtime;
}

The purpose of writing this function is to check whether the webpage is updated. If there is an update, download it to the local device; otherwise, 54. However, this function obtains the webpage Update time through the HTTP header. If the webpage's HTTP header does not contain lastmodified, there is no way to get the webpage update information. Is there any way to ensure that, without downloading a webpage, 100% detects any updates to a webpage? Also hope high hand guidance.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.