I’m developing an application that fetches data from homepages. I’m encountering an issue with accessing a specific URL: “https://www.intel.com/content/www/us/en/products/sku/218824/intel-w790-chipset/specifications.html”. While I can access this URL from my browser (Chrome) without any problems, attempting to connect from my Java app. results in a 403 status code (forbidden). Could anyone provide guidance on how to resolve this issue? Any help would be greatly appreciated. Thanks in advance!
The relevant code:
String url = "https://www.intel.com/content/www/us/en/products/sku/218824/intel-w790-chipset/specifications.html";
try {
boolean redirected = false;
URL obj = new URL(url);
HttpURLConnection conn = (HttpURLConnection) obj.openConnection();
// Set request method to GET
conn.setRequestMethod("GET");
// Add request headers
conn.setRequestProperty("User-Agent", "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/58.0.3029.110 Safari/537.36");
conn.setRequestProperty("Accept", "text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8");
conn.setRequestProperty("Accept-Language", "en-US,en;q=0.5");
conn.setRequestProperty("Accept-Encoding", "gzip, deflate, br");
conn.setRequestProperty("Connection", "keep-alive");
// Set the cookies allowed property
conn.setAllowUserInteraction(true);
// Handle the response
int responseCode = conn.getResponseCode();
...