Answer the question
In order to leave comments, you need to log in
How to parse onion sites in JAVA?
Hello.
I'm trying to write a site parser in the .onion zone
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.net.HttpURLConnection;
import java.net.InetSocketAddress;
import java.net.Proxy;
import java.net.URL;
public class main {
public static void main(String args[]) {
String query = "https://toster.ru";
HttpURLConnection connection = null;
try {
connection = (HttpURLConnection) new URL(query).openConnection();
connection.setRequestMethod("GET");
connection.setUseCaches(false);
//connection.setConnectTimeout(250);
//connection.setReadTimeout(250);
connection.connect();
StringBuilder sb = new StringBuilder();
if(HttpURLConnection.HTTP_OK == connection.getResponseCode()) {
BufferedReader in = new BufferedReader(new InputStreamReader(connection.getInputStream()));
String line;
while((line=in.readLine()) != null) {
sb.append(line);
sb.append("\r");
}
System.out.println(sb.toString());
}else {
System.out.println("Ошибка: "+connection.getResponseCode() + ", "+ connection.getResponseMessage());
}
}catch(Throwable cause) {
cause.printStackTrace();
} finally{
if(connection != null) {
connection.disconnect();
}
}
}
}
Answer the question
In order to leave comments, you need to log in
Here is for python. I haven't tried it myself, but I understood the principle that you need to communicate via Sox. Understand the principle, do it for java
https://jarroba.com/anonymous-scraping-by-tor-network/
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question