package br.com.alura.Principal;
import java.io.IOException;
import java.net.URI;
import java.net.URLEncoder;
import java.net.http.HttpClient;
import java.net.http.HttpRequest;
import java.net.http.HttpResponse;
import java.util.Scanner;
public class PrincipalComBusca {
public static void main(String[] args) throws IOException, InterruptedException {
Scanner leitura = new Scanner(System.in);
System.out.println("Digite o título do filme para busca: ");
var busca = leitura.nextLine();
String tituloCodificado = URLEncoder.encode(busca, "UTF-8");
String endereco = "https://www.omdbapi.com/?t=" + tituloCodificado + "&apikey=479a1bfc";
HttpClient client = HttpClient.newHttpClient();
HttpRequest request = HttpRequest.newBuilder()
.uri(URI.create(endereco))
.build();
HttpResponse<String> response = client
.send(request, HttpResponse.BodyHandlers.ofString());
System.out.println(response.body());
}
}