我正试图从Meetup-http://stream.meetup.com/2/open_events
但是我一直使用下面的代码得到错误403
URL meetupStream = new URL("http://stream.meetup.com/2/open_events");
BufferedReader in = new BufferedReader(new InputStreamReader(meetupStream.openStream()));
String inputLine;
while ((inputLine = in.readLine()) != null){
System.out.println(inputLine);
}
in.close();
流不需要任何身份验证,可以在浏览器中正常看到
你知道是什么导致了这样的错误吗?
一些Web服务器抱怨,如果您的请求看起来太惨淡,可能是因为他们认为它是由机器生成的?通常,他们可以通过您发送的邮件头来判断。这应该已经做到了:
URLConnection connection = new URL("http://stream.meetup.com/2/open_events").
openConnection();
connection.setRequestProperty("User-Agent", "Lynx");
connection.connect();
BufferedReader in = new BufferedReader(new InputStreamReader(
connection.getInputStream()));
String inputLine;
while ((inputLine = in.readLine()) != null){
System.out.println(inputLine);
}
in.close();