Duda con código Java
Publicado: 2013-01-05 18:40 @819
Ten el siguiente código :
Y me tira el siguiente error :
¿ Alguien me podría indicar cómo arreglo el código ?
Using java Syntax Highlighting
- //LocateIP 0.1
- //Coded By Doddy H
- package locateip;
- import java.util.Scanner;
- import java.net.*;
- import java.io.*;
- import java.util.regex.Matcher;
- import java.util.regex.Pattern;
- public class Main {
- public static void main(String[] args) throws Exception {
- String ip;
- Scanner host = new Scanner(System.in);
- System.out.println("\n\n-- == LocateIP 0.1 == --\n\n");
- System.out.println("[+] IP : ");
- ip = host.nextLine();
- String code;
- code = toma("http://www.melissadata.com/lookups/iplocation.asp?ipaddress="+ip);
- Pattern uno= null;
- Matcher dos= null;
- uno = Pattern.compile("City</td><td align=(.*?)><b>(.*?)</b></td>");
- dos = uno.matcher(code);
- if(!dos.find()) {
- System.out.println("[+] City : Not Found");
- } else {
- System.out.println("[+] City : "+dos.group(2));
- }
- uno = Pattern.compile("Country</td><td align=(.*?)><b>(.*?)</b></td>");
- dos = uno.matcher(code);
- if(!dos.find()) {
- System.out.println("[+] Country : Not Found");
- } else {
- System.out.println("[+] Country : "+dos.group(2));
- }
- uno = Pattern.compile("State or Region</td><td align=(.*?)><b>(.*?)</b></td>");
- dos = uno.matcher(code);
- if(!dos.find()) {
- System.out.println("[+] State or Region : Not Found");
- } else {
- System.out.println("[+] State or Region : "+dos.group(2));
- }
- code = toma("http://www.ip-adress.com/reverse_ip/");
- //uno = Pattern.compile("whois/(.*?)">Whois");
- //dos = uno.matcher(code);
- System.out.println("\n\n-- == Coded By Doddy H == --");
- }
- private static String toma(String url) throws Exception {
- String re;
- String total;
- StringBuffer conte = new StringBuffer(40);
- URL cargar = new URL(url);
- BufferedReader nave = new BufferedReader(
- new InputStreamReader(cargar.openStream()));
- while ((re = nave.readLine()) != null)
- conte.append(re);
- nave.close();
- return conte.toString();
- }
- }
- // The End ?
Coloreado en 0.053 segundos, usando GeSHi 1.0.8.4
Y me tira el siguiente error :
Using text Syntax Highlighting
Exception in thread "main" java.io.IOException: Server returned HTTP response code: 403 for URL: http://www.ip-adress.com/reverse_ip/
at sun.net.www.protocol.http.HttpURLConnection.getInputStream(HttpURLConnection.java:1436)
at java.net.URL.openStream(URL.java:1010)
at locateip.Main.toma(Main.java:74)
at locateip.Main.main(Main.java:57)
Java Result: 1
at sun.net.www.protocol.http.HttpURLConnection.getInputStream(HttpURLConnection.java:1436)
at java.net.URL.openStream(URL.java:1010)
at locateip.Main.toma(Main.java:74)
at locateip.Main.main(Main.java:57)
Java Result: 1
Coloreado en 0.000 segundos, usando GeSHi 1.0.8.4
¿ Alguien me podría indicar cómo arreglo el código ?