Initial data commit

This commit is contained in:
Ingy döt Net 2023-07-01 11:58:00 -04:00
parent 72d218235f
commit f23f22d71c
199087 changed files with 3378941 additions and 0 deletions

View file

@ -0,0 +1,38 @@
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.net.HttpURLConnection;
import java.net.URI;
import java.net.URISyntaxException;
import java.net.URL;
public final class WebScraping {
public static void main(String[] aArgs) {
try {
URI uri = new URI("https://www.rosettacode.org/wiki/Talk:Web_scraping").parseServerAuthority();
URL address = uri.toURL();
HttpURLConnection connection = (HttpURLConnection) address.openConnection();
BufferedReader reader = new BufferedReader( new InputStreamReader(connection.getInputStream()) );
final int responseCode = connection.getResponseCode();
System.out.println("Response code: " + responseCode);
String line;
while ( ! ( line = reader.readLine() ).contains("UTC") ) {
/* Empty block */
}
final int index = line.indexOf("UTC");
System.out.println(line.substring(index - 16, index + 4));
reader.close();
connection.disconnect();
} catch (IOException ioe) {
System.err.println("Error connecting to server: " + ioe.getCause());
} catch (URISyntaxException use) {
System.err.println("Unable to connect to URI: " + use.getCause());
}
}
}