Custom Headers
If you want to pass your own custom headers to scrape a website then you can do that by using custom_headers=true paramter. This parameter will let you pass your own headers to the request constructor. This can be helpful when you are trying to scrape a website that requires login cookies or something similar. There is absolutely no extra cost to using this parameter.
Usage
curl --header "X-customheader: bar" \
"https://api.scrapingdog.com/scrape?api_key=5e5a97e5b1ca5b194f42da86fr444356&url=http://httpbin.org/anything&custom_headers=true"import requests
url = "https://api.scrapingdog.com/scrape"
api_key = "5e5a97e5b1ca5b194f42da86fr444356"
headers = {
"X-customheader": "bar"
}
params = {
"api_key": api_key,
"url": "http://httpbin.org/anything",
"custom_headers": "true"
}
response = requests.get(url, headers=headers, params=params)
if response.status_code == 200:
print(response.text)
else:
print(f"Request failed with status code: {response.status_code}")
Last updated