Advertisement
dereksir

Untitled

Apr 6th, 2024
686
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.96 KB | None | 0 0
  1. package com.example;
  2.  
  3. // import the required classes
  4. import java.net.URI;
  5. import java.net.http.HttpClient;
  6. import java.net.http.HttpRequest;
  7. import java.net.http.HttpResponse;
  8. import java.net.http.HttpResponse.BodyHandlers;
  9.  
  10. public class Main {
  11.     public static void main(String[] args) {
  12.         // create an instance of HttpClient
  13.         HttpClient client = HttpClient.newHttpClient();
  14.         // build request using the Request Builder
  15.         HttpRequest request = HttpRequest.newBuilder()
  16.             .uri(URI.create("https://api.zenrows.com/v1/?apikey=<YOUR_ZENROWS_API_KEY>&url=https%3A%2F%2Fwww.g2.com%2Fproducts%2Fvisual-studio%2Freviews&js_render=true&premium_proxy=true"))
  17.             .build();
  18.         // send request asynchronously and print response to the console
  19.         client.sendAsync(request, BodyHandlers.ofString())
  20.             .thenApply(HttpResponse::body)
  21.             .thenAccept(System.out::println)
  22.             .join();
  23.     }
  24. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement