Самое простое решение (не зависящее от какой-либо сторонней библиотеки или платформы) - создать экземпляр URL-адреса, указывающий на веб-страницу / ссылку, которую вы хотите загрузить, и прочитать содержимое с использованием потоков.
Дляпример:
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.net.URL;
import java.net.URLConnection;
public class DownloadPage {
public static void main(String[] args) throws IOException {
// Make a URL to the web page
URL url = new URL("/6673251/ispolzovanie-java-dlya-izvlecheniya-dannyh-s-veb-stranitsy");
// Get the input stream through URL Connection
URLConnection con = url.openConnection();
InputStream is =con.getInputStream();
// Once you have the Input Stream, it's just plain old Java IO stuff.
// For this case, since you are interested in getting plain-text web page
// I'll use a reader and output the text content to System.out.
// For binary content, it's better to directly read the bytes from stream and write
// to the target file.
BufferedReader br = new BufferedReader(new InputStreamReader(is));
String line = null;
// read each line and write to System.out
while ((line = br.readLine()) != null) {
System.out.println(line);
}
}
}
Надеюсь, это поможет.