我正在尝试获取网站的CSS文件的内容....
<link href="/files/includes/templates-css-main.css" rel="stylesheet" type="text/css" />
Run Code Online (Sandbox Code Playgroud)
例如,它是http://paceoil.ca/的css ref的链接.当我尝试向此网址http://paceoil.ca/files/includes/templates-css-main.css发送获取css文件的请求时,我得到了意外的结果.
有帮助吗?提前致谢.
我正在尝试从url下载图像但是得到了java.io.IOException:exception.我的代码是:
public static void main(String[] args) throws MalformedURLException, IOException {
File picutreFile = new File("test.jpg");
FileUtils.copyURLToFile(new java.net.URL("http://paceoil.ca/files/includes/images/images-stories-presentation-october-icon-graphic.jpg"), picutreFile);
}
Run Code Online (Sandbox Code Playgroud)
当投掷时:
Exception in thread "main" java.io.IOException: Server returned HTTP response code: 403 for URL: http://paceoil.ca/files/includes/images/images-stories-presentation-october-icon-graphic.jpg
at sun.net.www.protocol.http.HttpURLConnection.getInputStream(Unknown Source)
at java.net.URL.openStream(Unknown Source)
at org.apache.commons.io.FileUtils.copyURLToFile(FileUtils.java:1460)
at com.hrant.Test.main(Test.java:14)
Run Code Online (Sandbox Code Playgroud)
这段代码适用于某些网址,但为此,我无法理解为什么不这样做.非常感谢.