From 118278b1394143dcdfcfcdde130f924011bbbf81 Mon Sep 17 00:00:00 2001 From: Juul Date: Sat, 23 Aug 2025 00:01:19 +0200 Subject: [PATCH] initial commit --- .gitignore | 35 ++++++++++++++++++++++ pom.xml | 17 +++++++++++ src/main/java/org/example/Main.java | 46 +++++++++++++++++++++++++++++ 3 files changed, 98 insertions(+) create mode 100644 .gitignore create mode 100644 pom.xml create mode 100644 src/main/java/org/example/Main.java diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..f1b939b --- /dev/null +++ b/.gitignore @@ -0,0 +1,35 @@ +target/ +!.mvn/wrapper/maven-wrapper.jar +!**/src/main/**/target/ +!**/src/test/**/target/ + +### IntelliJ IDEA ### +.idea/* +*.iws +*.iml +*.ipr + +### Eclipse ### +.apt_generated +.classpath +.factorypath +.project +.settings +.springBeans +.sts4-cache + +### NetBeans ### +/nbproject/private/ +/nbbuild/ +/dist/ +/nbdist/ +/.nb-gradle/ +build/ +!**/src/main/**/build/ +!**/src/test/**/build/ + +### VS Code ### +.vscode/ + +### Mac OS ### +.DS_Store \ No newline at end of file diff --git a/pom.xml b/pom.xml new file mode 100644 index 0000000..28b632d --- /dev/null +++ b/pom.xml @@ -0,0 +1,17 @@ + + + 4.0.0 + + org.example + cst-name-grabber + 1.0-SNAPSHOT + + + 21 + 21 + UTF-8 + + + \ No newline at end of file diff --git a/src/main/java/org/example/Main.java b/src/main/java/org/example/Main.java new file mode 100644 index 0000000..50a0cfe --- /dev/null +++ b/src/main/java/org/example/Main.java @@ -0,0 +1,46 @@ +package org.example; + +import java.io.BufferedReader; +import java.io.ByteArrayInputStream; +import java.io.IOException; +import java.io.InputStreamReader; +import java.net.URI; +import java.net.http.HttpClient; +import java.net.http.HttpRequest; +import java.net.http.HttpResponse; +import java.util.zip.GZIPInputStream; + +public class Main { + public static void main(String[] args) throws InterruptedException, IOException { + final URI uri = URI.create("https://coomer.st/api/v1/fansly/user/372647979531644928/posts"); + + HttpResponse response = makeRequest(uri); + decompress(response.body()); + + + } + + public static HttpResponse makeRequest(URI uri) throws IOException, InterruptedException { + HttpClient httpClient = HttpClient.newHttpClient(); + + HttpRequest request = HttpRequest.newBuilder() + .uri(uri) + .header("Accept", "text/css") + .header("Accept-Encoding", "gzip, deflate, br, zstd") + .build(); + + return httpClient.send(request, HttpResponse.BodyHandlers.ofByteArray()); + + } + + public static void decompress(byte[] responseBody) throws IOException { + GZIPInputStream gzipInputStream = new GZIPInputStream(new ByteArrayInputStream(responseBody)); + InputStreamReader reader = new InputStreamReader(gzipInputStream); + BufferedReader buffer = new BufferedReader(reader); + + String line; + while((line = buffer.readLine()) != null) { + System.out.println(line); + } + } +} \ No newline at end of file