Skip to main content

Making POST/PUT requests

To make a POST request, just use POST method along with optional body to Scraping Fish API:

import requests

payload = {
"api_key": "[your API key]",
"url": "https://httpbin.org/post",
}

data = {"key1": "value1", "key2": "value2"}

response = requests.post(f"https://scraping.narf.ai/api/v1/", params=payload, json=data)
print(response.content)

In the response from httpbin.org you get beck a JSON with data and headers which were send in the request.

You can issue a PUT request in analogous way.

You might also need to add a header like "Content-Type: application/json" or other custom headers as in the example below.

Example with headers​

In the example below, we make a POST request to httpbin.org and include custom header X-Custom-Header: value.

tip

Remember to encode headers parameter like in the example below.

import requests
import json

payload = {
"api_key": "[your API key]",
"url": "https://httpbin.org/post",
"headers": json.dumps({"x-custom-header": "value"}),
}

data = {"key1": "value1", "key2": "value2"}

response = requests.post(f"https://scraping.narf.ai/api/v1/", params=payload, json=data)
print(response.content)