Custom status code
Learn about custom status codes and find out how to indicate which status codes are acceptable and valuable to you.
By default, we assume the request is successful as long as it returns a 2xx or 4xx status code. However, sometimes websites return the required content together with a non-standard HTTPS status code. If one of your targets does that, you can indicate which status codes are acceptable and valuable to you. Add the X-Oxylabs-Successful-Status-Codes header with all the HTTP response codes that work for you.
Code examples
curl -k -v -x https://unblock.oxylabs.io:60000 \
-U 'USERNAME:PASSWORD' \
'https://ip.oxylabs.io/location' \
-H 'X-Oxylabs-Successful-Status-Codes: 500,501,502,503'import requests
# Use your Web Unblocker credentials here.
USERNAME, PASSWORD = 'YOUR_USERNAME', 'YOUR_PASSWORD'
# Define proxy dict.
proxies = {
'http': f'http://{USERNAME}:{PASSWORD}@unblock.oxylabs.io:60000',
'https': f'https://{USERNAME}:{PASSWORD}@unblock.oxylabs.io:60000',
}
headers = {
'X-Oxylabs-Successful-Status-Codes': '500,501,502,503'
}
response = requests.get(
'https://ip.oxylabs.io/location',
verify=False, # It is required to ignore certificate
proxies=proxies,
headers=headers,
)
# Print result page to stdout
print(response.text)
# Save returned HTML to result.html file
with open('result.html', 'w') as f:
f.write(response.text)Last updated
Was this helpful?

