POST, PUT & PATCH Requests
WebScrapingAPI is not limited to GET requests. You can send POST, PUT, or PATCH requests as well.
WebScrapingAPI is not limited to GET requests. You can now easily scrape the internet by sending POST, PUT or PATCH requests as well.
Currently in BETA version, the POST, PUT and PATCH requests are sent to the same base API URL. The only requirement for such requests is to pass the data (payload) alongside your request.
As you will see in the examples below, the only difference in implementation between the three is the HTTP method used. Apart from that, both requests are similar with respect to the endpoint and parameters passed.
Please make sure to update <YOUR_API_KEY> with your own API key. Find out how to obtain an API key.
POST Request
POST https://api.webscrapingapi.com/v2?api_key=<YOUR_API_KEY>&url=https://httpbin.org/post
Query Parameters
| Name | Type | Description |
|---|---|---|
api_key | string | <YOUR_API_KEY> |
url | string | https://httpbin.org/post/ |
Request Body
| Name | Type | Description |
|---|---|---|
foo | Any | bar |
Code Samples
curl --request POST \
--url "https://api.webscrapingapi.com/v2?api_key=<YOUR_API_KEY>&url=https%3A%2F%2Fhttpbin.org%2Fpost" \
--data '{"foo": "bar"}'const http = require("https");
const options = {
"method": "POST",
"hostname": "api.webscrapingapi.com",
"port": null,
"path": "/v2?api_key=<YOUR_API_KEY>&url=https%3A%2F%2Fhttpbin.org%2Fpost",
"headers": {}
};
const req = http.request(options, function (res) {
const chunks = [];
res.on("data", function (chunk) {
chunks.push(chunk);
});
res.on("end", function () {
const body = Buffer.concat(chunks);
console.log(body.toString());
});
});
req.write("{\n \"foo\": \"bar\"\n}");
req.end();import requests
API_KEY = '<YOUR_API_KEY>'
SCRAPER_URL = 'https://api.webscrapingapi.com/v2'
TARGET_URL = 'https://httpbin.org/post'
PARAMS = {
"api_key": API_KEY,
"url": TARGET_URL,
}
HEADERS = {
'WSA-Content-Type': 'application/json',
'WSA-Accept': 'application/json'
}
DATA = {
"foo": "bar"
}
response = requests.post(SCRAPER_URL, data=DATA, params=PARAMS, headers=HEADERS)
print(response.text)<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.webscrapingapi.com/v2?api_key=<YOUR_API_KEY>&url=https%3A%2F%2Fhttpbin.org%2Fpost",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => "{\n \"foo\": \"bar\"\n}",
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"io/ioutil"
"net/http"
"strings"
)
func main() {
url := "https://api.webscrapingapi.com/v2?api_key=<YOUR_API_KEY>&url=https%3A%2F%2Fhttpbin.org%2Fpost"
payload := strings.NewReader("{\n \"foo\": \"bar\"\n}")
req, _ := http.NewRequest("POST", url, payload)
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := ioutil.ReadAll(res.Body)
fmt.Println(res)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://api.webscrapingapi.com/v2?api_key=<YOUR_API_KEY>&url=https%3A%2F%2Fhttpbin.org%2Fpost")
.body("{\n \"foo\": \"bar\"\n}")
.asString();var client = new RestClient("https://api.webscrapingapi.com/v2?api_key=<YOUR_API_KEY>&url=https%3A%2F%2Fhttpbin.org%2Fpost");
var request = new RestRequest(Method.POST);
request.AddParameter("undefined", "{\n \"foo\": \"bar\"\n}", ParameterType.RequestBody);
IRestResponse response = client.Execute(request);require 'uri'
require 'net/http'
require 'openssl'
url = URI("https://api.webscrapingapi.com/v2?api_key=<YOUR_API_KEY>&url=https%3A%2F%2Fhttpbin.org%2Fpost")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
http.verify_mode = OpenSSL::SSL::VERIFY_NONE
request = Net::HTTP::Post.new(url)
request.body = "{\n \"foo\": \"bar\"\n}"
response = http.request(request)
puts response.read_bodyResponse example
{
"args": {},
"data": "",
"files": {},
"form": {
"foo": "bar"
},
"headers": {
"Accept": "text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8",
"Accept-Encoding": "gzip, deflate, br",
"Content-Length": "161",
"Content-Type": "multipart/form-data; boundary=--------------------------278908300530745447596209",
"Host": "httpbin.org",
"Upgrade-Insecure-Requests": "1",
"User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/94.0.4606.54 Safari/537.36",
"X-Amzn-Trace-Id": "Root=1-631b49ae-46b3c01b43d6982d4826fca3"
},
"json": null,
"origin": "192.3.214.227",
"url": "https://httpbin.org/post"
}PUT Request
PUT https://api.webscrapingapi.com/v2?api_key=<YOUR_API_KEY>&url=https://httpbin.org/put
Query Parameters
| Name | Type | Description |
|---|---|---|
api_key | string | <YOUR_API_KEY> |
url | string | https://httpbin.org/put/ |
Request Body
| Name | Type | Description |
|---|---|---|
foo | Any | bar |
Code Samples
curl --request PUT \
--url "https://api.webscrapingapi.com/v2?api_key=<YOUR_API_KEY>&url=https%3A%2F%2Fhttpbin.org%2Fput" \
--data '{"foo": "bar"}'const http = require("https");
const options = {
"method": "PUT",
"hostname": "api.webscrapingapi.com",
"port": null,
"path": "/v2?api_key=<YOUR_API_KEY>&url=https%3A%2F%2Fhttpbin.org%2Fput",
"headers": {}
};
const req = http.request(options, function (res) {
const chunks = [];
res.on("data", function (chunk) {
chunks.push(chunk);
});
res.on("end", function () {
const body = Buffer.concat(chunks);
console.log(body.toString());
});
});
req.write("{\n \"foo\": \"bar\"\n}");
req.end();import requests
API_KEY = '<YOUR_API_KEY>'
SCRAPER_URL = 'https://api.webscrapingapi.com/v2'
TARGET_URL = 'https://httpbin.org/put'
PARAMS = {
"api_key": API_KEY,
"url": TARGET_URL,
}
HEADERS = {
'WSA-Content-Type': 'application/json',
'WSA-Accept': 'application/json'
}
DATA = {
"foo": "bar"
}
response = requests.put(SCRAPER_URL, data=DATA, params=PARAMS, headers=HEADERS)
print(response.text)<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.webscrapingapi.com/v2?api_key=<YOUR_API_KEY>&url=https%3A%2F%2Fhttpbin.org%2Fput",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "PUT",
CURLOPT_POSTFIELDS => "{\n \"foo\": \"bar\"\n}",
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"io/ioutil"
"net/http"
"strings"
)
func main() {
url := "https://api.webscrapingapi.com/v2?api_key=<YOUR_API_KEY>&url=https%3A%2F%2Fhttpbin.org%2Fput"
payload := strings.NewReader("{\n \"foo\": \"bar\"\n}")
req, _ := http.NewRequest("PUT", url, payload)
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := ioutil.ReadAll(res.Body)
fmt.Println(res)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.put("https://api.webscrapingapi.com/v2?api_key=<YOUR_API_KEY>&url=https%3A%2F%2Fhttpbin.org%2Fput")
.body("{\n \"foo\": \"bar\"\n}")
.asString();var client = new RestClient("https://api.webscrapingapi.com/v2?api_key=<YOUR_API_KEY>&url=https%3A%2F%2Fhttpbin.org%2Fput");
var request = new RestRequest(Method.PUT);
request.AddParameter("undefined", "{\n \"foo\": \"bar\"\n}", ParameterType.RequestBody);
IRestResponse response = client.Execute(request);require 'uri'
require 'net/http'
require 'openssl'
url = URI("https://api.webscrapingapi.com/v2?api_key=<YOUR_API_KEY>&url=https%3A%2F%2Fhttpbin.org%2Fput")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
http.verify_mode = OpenSSL::SSL::VERIFY_NONE
request = Net::HTTP::Put.new(url)
request.body = "{\n \"foo\": \"bar\"\n}"
response = http.request(request)
puts response.read_bodyResponse example
{
"{foo: bar}": "",
"updatedAt": "2024-07-09T06:47:34.063Z",
"headers": {
"date": "Tue, 09 Jul 2024 06:47:34 GMT",
"content-type": "application/json; charset=utf-8",
"transfer-encoding": "chunked",
"connection": "keep-alive",
"x-powered-by": "Express",
"access-control-allow-origin": "*",
"etag": "W/\"38-xYucJZPnCu7IZXf4Jiw0lCr7Qkg\"",
"via": "1.1 vegur",
"cf-cache-status": "DYNAMIC",
"server": "cloudflare"
}
}PATCH Request
PATCH https://api.webscrapingapi.com/v1?api_key=<YOUR_API_KEY>&url=https://reqres.in/api/users/2
Query Parameters
| Name | Type | Description |
|---|---|---|
api_key | string | <YOUR_API_KEY> |
url | string | https://reqres.in/api/users/2 |
Request Body
| Name | Type | Description |
|---|---|---|
foo | Any | bar |
Code Samples
curl --request PATCH \
--url "https://api.webscrapingapi.com/v2?api_key=<YOUR_API_KEY>&url=https://reqres.in/api/users/2" \
--data '{"foo": "bar"}'const http = require("https");
const options = {
"method": "PATCH",
"hostname": "api.webscrapingapi.com",
"port": null,
"path": "/v2?api_key=<YOUR_API_KEY>&url=https://reqres.in/api/users/2",
"headers": {}
};
const req = http.request(options, function (res) {
const chunks = [];
res.on("data", function (chunk) {
chunks.push(chunk);
});
res.on("end", function () {
const body = Buffer.concat(chunks);
console.log(body.toString());
});
});
req.write("{\n \"foo\": \"bar\"\n}");
req.end();import requests
API_KEY = '<YOUR_API_KEY>'
SCRAPER_URL = 'https://api.webscrapingapi.com/v2'
TARGET_URL = 'https://reqres.in/api/users/2'
PARAMS = {
"api_key": API_KEY,
"url": TARGET_URL,
}
HEADERS = {
'WSA-Content-Type': 'application/json',
'WSA-Accept': 'application/json'
}
DATA = {
"foo": "bar"
}
response = requests.patch(SCRAPER_URL, data=DATA, params=PARAMS, headers=HEADERS)
print(response.text)<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.webscrapingapi.com/v2?api_key=<YOUR_API_KEY>&url=https://reqres.in/api/users/2",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "PATCH",
CURLOPT_POSTFIELDS => "{\n \"foo\": \"bar\"\n}",
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"io/ioutil"
"net/http"
"strings"
)
func main() {
url := "https://api.webscrapingapi.com/v2?api_key=<YOUR_API_KEY>&url=https://reqres.in/api/users/2"
payload := strings.NewReader("{\n \"foo\": \"bar\"\n}")
req, _ := http.NewRequest("PATCH", url, payload)
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := ioutil.ReadAll(res.Body)
fmt.Println(res)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.patch("https://api.webscrapingapi.com/v2?api_key=<YOUR_API_KEY>&url=https://reqres.in/api/users/2")
.body("{\n \"foo\": \"bar\"\n}")
.asString();var client = new RestClient("https://api.webscrapingapi.com/v2?api_key=<YOUR_API_KEY>&url=https://reqres.in/api/users/2");
var request = new RestRequest(Method.PATCH);
request.AddParameter("undefined", "{\n \"foo\": \"bar\"\n}", ParameterType.RequestBody);
IRestResponse response = client.Execute(request);require 'uri'
require 'net/http'
require 'openssl'
url = URI("https://api.webscrapingapi.com/v2?api_key=<YOUR_API_KEY>&url=https://reqres.in/api/users/2")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
http.verify_mode = OpenSSL::SSL::VERIFY_NONE
request = Net::HTTP::Patch.new(url)
request.body = "{\n \"foo\": \"bar\"\n}"
response = http.request(request)
puts response.read_bodyResponse example
{
"name": "morpheus",
"job": "zion resident",
"updatedAt": "2024-07-09T06:47:34.063Z"
}