C
C
coreglot2019-08-17 18:25:59
Java
coreglot, 2019-08-17 18:25:59

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();
      }
    }
  }

}

Here's what I got - this code quietly parses sites on the open Internet. But domains in the onion zone refuse to see.
How to connect it to the Tor network?
Can this be done without using a browser?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
spaceatmoon, 2019-08-17
@spaceatmoon

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/

Tyk
Если не секрет, что вы нашли интересного такого, что приходится парсить? Разве tor не помойка?

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question