Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Latest commit

 

History

History
History
45 lines (38 loc) · 1.61 KB

File metadata and controls

45 lines (38 loc) · 1.61 KB
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
import java.io.IOException;
import java.io.InputStream;
import java.net.MalformedURLException;
import java.net.URL;
import java.net.URLConnection;
import java.nio.file.Files;
import java.nio.file.Paths;
import java.nio.file.StandardCopyOption;
import java.security.NoSuchAlgorithmException;
import java.util.HashMap;
import java.util.Map;
public class Client {
public static void main(String[] args) throws MalformedURLException, IOException, NoSuchAlgorithmException {
String customerKey = "PUT_YOUR_CUSTOMER_KEY_HERE";
String secretPhrase = "";//leave secret phrase empty, if not needed
ScreenshoMachine sm = new ScreenshoMachine(customerKey, secretPhrase);
Map<String, String> options = new HashMap<String, String>();
// mandatory parameter
options.put("url", "https://www.google.com");
// all next parameters are optional, see our website screenshot API guide for more details
options.put("dimension", "1366x768"); // or "1366xfull" for full length screenshot
options.put("device", "desktop");
options.put("format", "png");
options.put("cacheLimit", "0");
options.put("delay", "200");
options.put("zoom", "100");
String apiUrl = sm.generateScreenshotApiUrl(options);
// put link to your html code
System.out.println(apiUrl);
// or save screenshot as an image
URLConnection openConnection = new URL(apiUrl).openConnection();
openConnection.addRequestProperty("User-Agent", "Mozilla/4.0");
InputStream in = openConnection.getInputStream();
String output = "out.png";
Files.copy(in, Paths.get(output), StandardCopyOption.REPLACE_EXISTING);
System.out.println("Screenshot saved as " + output);
}
}
Morty Proxy This is a proxified and sanitized view of the page, visit original site.