Response code 404 when sendig a GET request to the a Website

247 views Asked by At

I am attempting to make the beginning parts of a shopify sneaker bot so I am using HTTP client and request to send a get request to the website so that I can get to the products/json path. This was working before however, when I send request the response always returns the body as "" and gives the response code 404 which means that the page is not found when the website is still online.#

Is this because of something on my end or what ?

thanks

public class Cla {
public Cla(){
}
public static void main(String[] args) throws InterruptedException, IOException {
   Parse(BuildConnection("https://uk.octobersveryown.com/"));
}
public static String BuildConnection(String URL) throws InterruptedException, IOException {
    WebElement search ;
    WebElement press;
    HttpClient client = HttpClient.newBuilder().connectTimeout(Duration.ofSeconds(10)).build();
    URL += "/products.json";
    HttpRequest request = HttpRequest.newBuilder()
            .uri(URI.create(URL + "/products.json"))
            .build();
    HttpResponse<String> response = null;
    response = client.send(request,HttpResponse.BodyHandlers.ofString());

    System.out.println(response.body());
    return response.body();
}
public static String Parse(String responseBody){
    String str = responseBody;
    str = str.replace("{\"products\":", "");
    str = str.replace("]}]}]}","]}]}]");
    JSONArray arr = new JSONArray(str);
    for (int i = 0; i < arr.length(); i++) {
        JSONObject arrs = arr.getJSONObject(i);
        String handle_str = arrs.getString("handle");
       
        System.out.println(handle_str);
    }
    return null;
}
1

There are 1 answers

0
passer-by On

You do this

 URL += "/products.json";

then this

.uri(URI.create(URL + "/products.json"))

the net result being you are looking for

https://uk.octobersveryown.com/products.json/products.json