将html代码添加到网站首页,将HTML代码添加到列表中

所以我试图制作一个刮板作为我的第一个项目。我相当新,而且我不太了解我写的代码。虽然我不明白,但在eclipse中似乎没有任何错误。将HTML代码添加到列表中

我写的代码是假设读取html源文件并将它逐行添加到数组列表中,直到它不能,然后返回列表。我真的不知道它是否简单,但我不知道它为什么不起作用。

import java.util.ArrayList;

import java.io.InputStreamReader;

import java.net.URL;

import java.util.List;

import java.io.BufferedReader;

public class Scraper {

public static void main(String [] args)throws Exception{

get_url_source("https://statsroyale.com/clan/99VUU8Y");

}

public static List get_url_source(String URL)throws Exception {

List source = new ArrayList <>();

URL stats = new URL("https://statsroyale.com/clan/99VUU8Y");

BufferedReader in = new BufferedReader(new InputStreamReader(stats.openStream()));

String inputLine;

while ((inputLine = in.readLine()) != null)

source.add(inputLine);

return source;

}

}

以及我真的很抱歉,如果格式是错误的。仍在尝试学习格式化如何工作以及如何进行。 (这不是那么简单,因为它似乎)

的错误味精很长,但这里是......

Exception in thread "main" java.io.IOException: Server returned HTTP response code: 403 for URL: https://statsroyale.com/clan/99VUU8Y

at sun.net.www.protocol.http.HttpURLConnection.getInputStream0(Unknown Source)

at sun.net.www.protocol.http.HttpURLConnection.getInputStream(Unknown Source)

at sun.net.www.protocol.https.HttpsURLConnectionImpl.getInputStream(Unknown Source)

at java.net.URL.openStream(Unknown Source)

at Scraper.get_url_source(Scraper.java:21)

at Scraper.main(Scraper.java:13)

2017-08-01

Jblue

+0

什么是403错误 - 见https://www.lifewire.com/403-forbidden-error-explained -2617989 –

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值