For the complete documentation index, see llms.txt. This page is also available as Markdown.

Headers & Cookies

Learn how to use custom headers and cookies to improve site access rates.

Web Unblocker optimizes data access by using headers and cookies predefined by our team.

Custom headers

If you require the use of your own headers, you can do so by adding the x-oxylabs-force-headers: 1 header into your requests. Web Unblocker will merge your custom headers into the predefined headers set and then use it to access the website.

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

If you require the use of your own cookies, you can do so by adding the x-oxylabs-force-cookies:1 header in your requests. Web Unblocker will merge your custom cookies into the predefined cookies set and then use it to access the website.

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?