POST, PUT & PATCH Requests
WebScrapingAPI is not limited to GET requests. You can now easily scrape the internet by sending POST, PUT or PATCH requests as well.
Last updated
WebScrapingAPI is not limited to GET requests. You can now easily scrape the internet by sending POST, PUT or PATCH requests as well.
Last updated
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.
POST
https://api.webscrapingapi.com/v2?api_key=<YOUR_API_KEY>&url=https://httpbin.org/post
Please make sure to update <YOUR_API_KEY>
with your own API key. Find out how to obtain an API key.
Name | Type | Description |
---|---|---|
Name | Type | Description |
---|---|---|
{
"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",
"Cookie": "_ym_d=1662526544; _ym_uid=1662526544185865588; _sp_id.d61c=748a9bc6-a5c7-4150-8fd0-414c0f2bfef5.1662526544.1.1662526544..929d5975-1989-4385-86c9-58f4912eae17....0; _sp_ses.d61c=*; _dc_gtm_UA-1873769-1=1; _ga=GA1.2.2035572845.1662526542; _gid=GA1.2.1990048789.1662526542; MVID_ENVCLOUD=prod2; MVID_SMART_BANNER_BOTTOM=true; CACHE_INDICATOR=false; COMPARISON_INDICATOR=false; JSESSIONID=QpTvjYkL9QXSgpwGw4QZhJ8K8J8Gpdm1kJJXw0KG0j1b2xXhN7pJ!1498067355; MVID_CITY_ID=CityCZ_975; MVID_KLADR_ID=7700000000000; MVID_REGION_ID=1; MVID_REGION_SHOP=S002; MVID_TIMEZONE_OFFSET=3; bIPs=2105588670; flacktory=no; MVID_AB_SERVICES_DESCRIPTION=var2; MVID_BLACK_FRIDAY_ENABLED=true; MVID_CART_AVAILABILITY=true; MVID_CATALOG_STATE=1; MVID_CREDIT_AVAILABILITY=true; MVID_FILTER_CODES=true; MVID_FILTER_TOOLTIP=1; MVID_FLOCKTORY_ON=true; MVID_GIFT_KIT=true; MVID_HANDOVER_SUMMARY=true; MVID_IS_NEW_BR_WIDGET=true; MVID_LAYOUT_TYPE=1; MVID_LP_SOLD_VARIANTS=1; MVID_MCLICK=true; MVID_MINDBOX_DYNAMICALLY=true; MVID_MINI_PDP=true; MVID_MOBILE_FILTERS=true; MVID_NEW_ACCESSORY=true; MVID_NEW_DESKTOP_FILTERS=true; MVID_NEW_LK_CHECK_CAPTCHA=true; MVID_NEW_LK_OTP_TIMER=true; MVID_NEW_MBONUS_BLOCK=true; MVID_PROMO_CATALOG_ON=true; MVID_SERVICES=111; MVID_SERVICES_MINI_BLOCK=var2; MVID_WEBP_ENABLED=true; SENTRY_ERRORS_RATE=0.1; SENTRY_TRANSACTIONS_RATE=0.5; HINTS_FIO_COOKIE_NAME=2; MVID_ADDRESS_COMMENT_AB_TEST=2; MVID_CALC_BONUS_RUBLES_PROFIT=false; MVID_CART_MULTI_DELETE=false; MVID_GEOLOCATION_NEEDED=true; MVID_GET_LOCATION_BY_DADATA=DaData; MVID_GUEST_ID=21402680884; MVID_TAXI_DELIVERY_INTERVALS_VIEW=new; NEED_REQUIRE_APPLY_DISCOUNT=true; PICKUP_SEAMLESS_AB_TEST=2; PRESELECT_COURIER_DELIVERY_FOR_KBT=true; PROMOLISTING_WITHOUT_STOCK_AB_TEST=2; searchType2=2; __lhash_=c8f8689df5f9f7ae2c2b1ff6ad376902; __hash_=faf9a07c2b595ee1d591322e71aecc95; __cap_=a193bd59f0e68a94f271a1413394835d; __cap_p_=1,0",
"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"
}
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": "GET",
"hostname": "api.webscrapingapi.com",
"port": null,
"path": "/v2?api_key=<YOUR_API_KEY>&url=https%3A%2F%2Fhttpbin.org%2Fget&proxy_type=datacenter",
"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.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 = {
"query":"\\n mutation {\\n createCartItem(\\n \\n menuItemId: \\\ '105097698\\\'\\n …\\n \)} \""
}
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"
"strings"
"net/http"
"io/ioutil"
)
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_body
PUT
https://api.webscrapingapi.com/v2?api_key=<YOUR_API_KEY>&url=https://httpbin.org/put
Please make sure to update <YOUR_API_KEY>
with your own API key. Find out how to obtain an API key.
{
"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",
"Cookie": "_ym_d=1662526544; _ym_uid=1662526544185865588; _sp_id.d61c=748a9bc6-a5c7-4150-8fd0-414c0f2bfef5.1662526544.1.1662526544..929d5975-1989-4385-86c9-58f4912eae17....0; _sp_ses.d61c=*; _dc_gtm_UA-1873769-1=1; _ga=GA1.2.2035572845.1662526542; _gid=GA1.2.1990048789.1662526542; MVID_ENVCLOUD=prod2; MVID_SMART_BANNER_BOTTOM=true; CACHE_INDICATOR=false; COMPARISON_INDICATOR=false; JSESSIONID=QpTvjYkL9QXSgpwGw4QZhJ8K8J8Gpdm1kJJXw0KG0j1b2xXhN7pJ!1498067355; MVID_CITY_ID=CityCZ_975; MVID_KLADR_ID=7700000000000; MVID_REGION_ID=1; MVID_REGION_SHOP=S002; MVID_TIMEZONE_OFFSET=3; bIPs=2105588670; flacktory=no; MVID_AB_SERVICES_DESCRIPTION=var2; MVID_BLACK_FRIDAY_ENABLED=true; MVID_CART_AVAILABILITY=true; MVID_CATALOG_STATE=1; MVID_CREDIT_AVAILABILITY=true; MVID_FILTER_CODES=true; MVID_FILTER_TOOLTIP=1; MVID_FLOCKTORY_ON=true; MVID_GIFT_KIT=true; MVID_HANDOVER_SUMMARY=true; MVID_IS_NEW_BR_WIDGET=true; MVID_LAYOUT_TYPE=1; MVID_LP_SOLD_VARIANTS=1; MVID_MCLICK=true; MVID_MINDBOX_DYNAMICALLY=true; MVID_MINI_PDP=true; MVID_MOBILE_FILTERS=true; MVID_NEW_ACCESSORY=true; MVID_NEW_DESKTOP_FILTERS=true; MVID_NEW_LK_CHECK_CAPTCHA=true; MVID_NEW_LK_OTP_TIMER=true; MVID_NEW_MBONUS_BLOCK=true; MVID_PROMO_CATALOG_ON=true; MVID_SERVICES=111; MVID_SERVICES_MINI_BLOCK=var2; MVID_WEBP_ENABLED=true; SENTRY_ERRORS_RATE=0.1; SENTRY_TRANSACTIONS_RATE=0.5; HINTS_FIO_COOKIE_NAME=2; MVID_ADDRESS_COMMENT_AB_TEST=2; MVID_CALC_BONUS_RUBLES_PROFIT=false; MVID_CART_MULTI_DELETE=false; MVID_GEOLOCATION_NEEDED=true; MVID_GET_LOCATION_BY_DADATA=DaData; MVID_GUEST_ID=21402680884; MVID_TAXI_DELIVERY_INTERVALS_VIEW=new; NEED_REQUIRE_APPLY_DISCOUNT=true; PICKUP_SEAMLESS_AB_TEST=2; PRESELECT_COURIER_DELIVERY_FOR_KBT=true; PROMOLISTING_WITHOUT_STOCK_AB_TEST=2; searchType2=2; __lhash_=c8f8689df5f9f7ae2c2b1ff6ad376902; __hash_=faf9a07c2b595ee1d591322e71aecc95; __cap_=a193bd59f0e68a94f271a1413394835d; __cap_p_=1,0",
"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"
}
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 = {
"query":"\\n mutation {\\n createCartItem(\\n \\n menuItemId: \\\ '105097698\\\'\\n …\\n \)} \""
}
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"
"strings"
"net/http"
"io/ioutil"
)
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_body
PATCH
https://api.webscrapingapi.com/v1?api_key=<YOUR_API_KEY>&url=https://reqres.in/api/users/2
Please make sure to update <YOUR_API_KEY>
with your own API key. Find out how to obtain an API key.
{
"{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",
"report-to": "{\"group\":\"heroku-nel\",\"max_age\":3600,\"endpoints\":[{\"url\":\"https://nel.heroku.com/reports?ts=1720507654&sid=c4c9725f-1ab0-44d8-820f-430df2718e11&s=DM8%2BgbKWbQsKLgdybhmThpAaNqhBTu5jphWoRDmYLag%3D\"}]}",
"reporting-endpoints": "heroku-nel=https://nel.heroku.com/reports?ts=1720507654&sid=c4c9725f-1ab0-44d8-820f-430df2718e11&s=DM8%2BgbKWbQsKLgdybhmThpAaNqhBTu5jphWoRDmYLag%3D",
"nel": "{\"report_to\":\"heroku-nel\",\"max_age\":3600,\"success_fraction\":0.005,\"failure_fraction\":0.05,\"response_headers\":[\"Via\"]}",
"x-powered-by": "Express",
"access-control-allow-origin": "*",
"etag": "W/\"38-xYucJZPnCu7IZXf4Jiw0lCr7Qkg\"",
"via": "1.1 vegur",
"cf-cache-status": "DYNAMIC",
"server": "cloudflare",
"cf-ray": "8a065d054ede9932-ARN",
"content-encoding": "br"
}
}
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 = {
"query":"\\n mutation {\\n createCartItem(\\n \\n menuItemId: \\\ '105097698\\\'\\n …\\n \)} \""
}
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"
"strings"
"net/http"
"io/ioutil"
)
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_body
Name | Type | Description |
---|---|---|
Name | Type | Description |
---|---|---|
Name | Type | Description |
---|---|---|
Name | Type | Description |
---|---|---|