Headers & Cookies
Learn how to use custom headers and cookies to improve unblocking success.
Custom headers
Code examples
curl -k -v -x https://unblock.oxylabs.io:60000 \
-U 'USERNAME:PASSWORD' \
'https://ip.oxylabs.io/headers' \
-H 'x-oxylabs-force-headers: 1' \
-H 'Accept-Language: en-GB' \
-H 'Your-Header-Name: interesting header content'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-force-headers': '1',
'Accept-Language': 'en-GB',
'Your-Header-Name': 'interesting header content'
}
response = requests.get(
'https://ip.oxylabs.io/headers',
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)Custom cookies
Code examples
curl -k -v -x https://unblock.oxylabs.io:60000 \
-U 'USERNAME:PASSWORD' \
'https://example.com' \
--cookie 'NID=1234567890' \
-H 'x-oxylabs-force-cookies: 1'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 = {
'Cookie': 'NID=1234567890',
'x-oxylabs-force-cookies': '1'
}
response = requests.get(
'https://example.com',
proxies=proxies,
headers=headers,
verify=False # Ignore certificate verification
)
# 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?

