-
Notifications
You must be signed in to change notification settings - Fork 306
Open
Labels
feature_requestfor feature requestfor feature request
Description
We could try to use an external API such as https://jina.ai/reader/:
curl "https://r.jina.ai/" \
-H "Content-Type: application/json" \
-H "X-Return-Format: screenshot" \
-d @- <<EOFEOF
{
"url": "https://www.google.com",
"pdf": "<BASE_64_OF_YOUR_PDF_FILE>"
}
EOFEOFOr in Java, something like:
import java.io.OutputStream;
import java.net.HttpURLConnection;
import java.net.URL;
public class CurlToJava {
public static void main(String[] args) {
String urlString = "https://r.jina.ai/";
String jsonInputString = "{"
+ "\"url\": \"https://www.example.com\","
+ "\"pdf\": \"<BASE_64_OF_YOUR_PDF_FILE>\""
+ "}";
try {
URL url = new URL(urlString);
HttpURLConnection connection = (HttpURLConnection) url.openConnection();
connection.setRequestMethod("POST");
connection.setRequestProperty("Content-Type", "application/json");
connection.setRequestProperty("X-Return-Format", "screenshot");
connection.setDoOutput(true);
try (OutputStream os = connection.getOutputStream()) {
byte[] input = jsonInputString.getBytes("utf-8");
os.write(input, 0, input.length);
}
int responseCode = connection.getResponseCode();
System.out.println("Response Code: " + responseCode);
// Optionally handle the response here...
} catch (Exception e) {
e.printStackTrace();
}
}
}Or get a specific page:
curl 'https://r.jina.ai/' -XPOST -F 'file=@FILE_PATH' -F 'url=blob:_#2' -H 'x-return-format: screenshot'Or use a similar approach of https://github.com/btimby/thumbnailer
Metadata
Metadata
Assignees
Labels
feature_requestfor feature requestfor feature request