HttpURLConnection 으로 html 파일로 다운받는 코드 짰는데요
돌리니깐 403에러 뜨는데 왜그런거에요??
public class h_SourceViewer4 {
/**
* @param args
*/
public static void main(String[] args) {
// TODO Auto-generated method stub
try {
URL u = new URL("http://www.google.com/search?원하는검색데이터");
HttpURLConnection uc = (HttpURLConnection) u.openConnection();
try (InputStream in = new BufferedInputStream(uc.getInputStream())) {
Reader r = new InputStreamReader(in);
FileOutputStream output = new FileOutputStream("E://hanbat.html");
int c;
while ((c = r.read()) != -1) {
output.write(c);
}
}
} catch (MalformedURLException ex) {
System.err.println("This is not a parseable URL");
} catch (IOException ex) {
System.err.println(ex);
}
}
}
// 해결완료 //
Https 이사람아 - 관악구 서원동 거주 한솔근
형 s 넣어도 안돌아가서 빼고돌려봤는데도 똑같아 ㅠ
엥 ㄱㄷ려보삼 - 관악구 서원동 거주 한솔근
ㄳㄳ...
헤더 추가 안 해서 그런감
C# 으로 똑같이 짰는데 난 잘됨
이클립스문제인가..
user-agent 추가해봐
uc.setRequestProperty("User-Agent", "Mozilla/4.0");
아 이게문제였네 스택오버플로우에도 추가하라고하네 형 고마워 땡큐땡큐
ㅎㅎㅎ... 즐코딩하셈
user-agent요 ?? 알겠슴다!
꺄아악 좆바 깔아서 먼지 볼려고 했는데