Making POST/PUT requests
To make a POST or PUT request with Scraping Fish API just use POST or PUT method when calling /api/v1/
endpoint along with optional body.
Example
The following examples showcases how to issue a POST request with Scraping Fish. You can make PUT requests in an analogous way, swapping POST with PUT.
POST
/api/v1/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 might also need to add a header such as 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
.
Remember to encode headers
parameter like in the example below.
POST
/api/v1/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)