Making POST/PUT requests
To make a POST request, just use POST method along with optional body to Scraping Fish API:
- Python
- NodeJS
- cURL
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)
const axios = require("axios");
const payload = {
api_key: "[your API key]",
url: "https://httpbin.org/post",
};
const data = { key1: "value1", key2: "value2" };
const response = await axios.post("https://scraping.narf.ai/api/v1/", data, { params: payload });
console.log(response.data);
curl -X POST \
--data '{"key1":"value1","key2":"value2"}' \
'https://scraping.narf.ai/api/v1/?api_key=[your API key]&url=https://httpbin.org/post'
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.
- Python
- NodeJS
- cURL
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)
const axios = require("axios");
const payload = {
api_key: "[your API key]",
url: "https://httpbin.org/post",
headers: JSON.stringify({"x-custom-header": "value"}),
};
const data = { key1: "value1", key2: "value2" };
const response = await axios.post("https://scraping.narf.ai/api/v1/", data, { params: payload });
console.log(response.data);
curl -X POST \
--data '{"key1":"value1","key2":"value2"}' \
'https://scraping.narf.ai/api/v1/?api_key=[your API key]&url=https://httpbin.org/post&headers=%7B%22x-custom-header%22%3A%22value%22%7D'