有 Java 编程相关的问题?

你可以在下面搜索框中键入要查询的问题!


共 (3) 个答案

  1. # 1 楼答案

    你可以那样做

    Uri myUri = new Uri(url);
    
    // Creates an HttpWebRequest for the specified URL. 
    HttpWebRequest myHttpWebRequest = (HttpWebRequest)WebRequest.Create(myUri); 
    HttpWebResponse myHttpWebResponse = (HttpWebResponse)myHttpWebRequest.GetResponse();
    
    DateTime today = DateTime.Now;
    // Uses the LastModified property to compare with today's date.
    if (DateTime.Compare(today,myHttpWebResponse.LastModified) == 0)
        Console.WriteLine("\nThe requested URI entity was modified today");
    else
        if (DateTime.Compare(today,myHttpWebResponse.LastModified) == 1)
            Console.WriteLine("\nThe requested URI was last modified on:{0}",
                            myHttpWebResponse.LastModified);
        // Releases the resources of the response.
    
    myHttpWebResponse.Close(); 
    
  2. # 2 楼答案

    Yes可以使用CURLcurl_getinfo获取文件信息,而不必返回整个正文

    范例

    $curl = curl_init('URL_TO_XML');
    curl_setopt($curl, CURLOPT_NOBODY, true);
    curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
    curl_setopt($curl, CURLOPT_FILETIME, true);
    $result = curl_exec($curl);
    if ($result === false) {
        die (curl_error($curl)); 
    }
    $timestamp = curl_getinfo($curl, CURLINFO_FILETIME);
    if ($timestamp != -1) { 
        echo date("Y-m-d H:i:s", $timestamp);
    } 
    
  3. # 3 楼答案

    否。
    因为它是一个web url,您可能无法获得web服务器公开的更多信息