小编Hra*_*yan的帖子

如何从网站获取css文件?

我正在尝试获取网站的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文件的请求时,我得到了意外的结果.

有帮助吗?提前致谢.

html css resources

4
推荐指数
1
解决办法
3万
查看次数

无法下载图片

我正在尝试从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)

这段代码适用于某些网址,但为此,我无法理解为什么不这样做.非常感谢.

java

3
推荐指数
1
解决办法
1875
查看次数

标签 统计

css ×1

html ×1

java ×1

resources ×1