1

I am trying to make a request using Urlfetchapp, this has been working fine for a month but now it starts giving an Error 403 message. The sample code is:

function fetchWithRetry() {
 
  var url = 'https://www.futbin.com/25/player/55430/robin-koch'; //sample url

  for (var attempt = 0; attempt < 4; attempt++) {
    try {
      var result = UrlFetchApp.fetch(url);
      return result.getContentText();  // If successful, return the result
    } catch (error) {
      Logger.log("Attempt " + (attempt + 1) + " failed for URL: " + url + ". Error: " + error);  // Wait before retrying
    }
  }
  return null;  // If all attempts fail, return null
} 

The error looks like this:

https://www.futbin.com/25/player/55430/robin-koch. Error: Exception: Request failed for https://www.futbin.com returned code 403. Truncated server response: Just a moment...<meta htt... (use muteHttpExceptions option to examine full response)

Following this question, I tried adding headers in the request:

   var url = 'https://www.futbin.com/25/player/55430/robin-koch'; //sample url
   var headers = {
    "authority": "www.futbin.com",
    "method": "GET",
    "referer": "https://www.google.com/",
    "sec-ch-ua": "\"Google Chrome\";v=\"129\", \"Not=A?Brand\";v=\"8\", \"Chromium\";v=\"129\"",
    "user-agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/547.36 (KHTML, like Gecko) Chrome/127.0.0.0 Safari/547.36"
  };
  
  var options = {
    "method": "GET",
    "headers": headers,
    "muteHttpExceptions": true
  };

 var result = UrlFetchApp.fetch(url,options);

But it did not work out either. Can we use a proxy in the request header as mentioned in this answer? I am trying to get the following values from the webpage as a result, I would appreciate any workaround to resolve this:

Values to get

12
  • It is entirely possible they have a monthly request limit. Have you checked their site? Commented Oct 3, 2024 at 3:25
  • I am unsure if there is any request limit because I am not using their API. I am just getting publicly available data from the fetch response
    – EagleEye
    Commented Oct 3, 2024 at 3:28
  • Whether you call it one or not, you're using their site as an API. That web site is copyrighted, so they may have a request limit to protect their intellectual property. Commented Oct 3, 2024 at 3:31
  • According [this article ](developer.mozilla.org/en-US/docs/Web/HTTP/Status/403), The HTTP 403 Forbidden client error response status code indicates that the server understood the request but refused to process it. This status is similar to 401, except that for 403 Forbidden responses, authenticating or re-authenticating makes no difference. The request failure is tied to application logic, such as insufficient permissions to a resource or action. You might want to consider looking for documentation about accessing the given website
    – 4thAnd1
    Commented Oct 3, 2024 at 6:02
  • It worked fine until today, I am not sure what has changed in a day. I have updated my question with the required values to get from webpage
    – EagleEye
    Commented Oct 3, 2024 at 6:07

0

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.