Basic Proxy Requests
Making requests with Web Stealth Proxy is easy, especially if you have previously used regular proxies for web scraping.
A simple way to get started is to send a basic request without any special options. Web Stealth Proxy will take care of adding the necessary headers and selecting the best proxy for you.
Web Stealth Proxy Integration Examples
#1: GET Requests
curl -k -x "http://stealthproxy.webscrapingapi.com:80" -U "<YOUR-PROXY-USERNAME>:<YOUR-PROXY-PASSWORD>" -X GET "https://httpbin.org/get"
const axios = require('axios');
axios.get('http://httpbin.org/get', {
proxy: {
host: 'stealthproxy.webscrapingapi.com',
port: 80,
auth: {
username: '<YOUR-PROXY-USERNAME>',
password: '<YOUR-PROXY-PASSWORD>'
}
}
}).then(function (response) {
console.log(response.data);
}, (err) => {
console.log(err)
})
import requests
USERNAME = '<YOUR-PROXY-USERNAME>'
PASSWORD = '<YOUR-PROXY-PASSWORD>'
TARGET_URL = 'https://httpbin.org/get'
PROXY = {
"https": f"http://{ USERNAME }:{ PASSWORD }@stealthproxy.webscrapingapi.com:80"
}
response = requests.get(
url=TARGET_URL,
proxies=PROXY,
verify=False
)
print(response.text)
<?php
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, 'https://httpbin.org/get');
curl_setopt($ch, CURLOPT_PROXY, 'http://<YOUR-PROXY-USERNAME>:<YOUR-PROXY-PASSWORD>@stealthproxy.webscrapingapi.com:80');
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'GET');
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
$response = curl_exec($ch);
if (!$response) {
die('Error: "'.curl_error($ch).'" - Code: '.curl_errno($ch));
}
echo 'HTTP Status Code: '.curl_getinfo($ch, CURLINFO_HTTP_CODE) . PHP_EOL;
echo 'Response Body: '.$response . PHP_EOL;
curl_close($ch);
?>
package main
import (
"crypto/tls"
"fmt"
"io/ioutil"
"net/http"
"net/url"
)
func send_proxy() {
proxyStr := "https://<YOUR-PROXY-USERNAME>:<YOUR-PROXY-PASSWORD>@stealthproxy.webscrapingapi.com:8000"
proxyURL, err := url.Parse(proxyStr)
if err != nil {
fmt.Println(err)
}
transport := &http.Transport{
Proxy: http.ProxyURL(proxyURL),
TLSClientConfig: &tls.Config{InsecureSkipVerify: true},
}
client := &http.Client{
Transport: transport,
}
req, err := http.NewRequest("GET", "https://httpbin.org/get", nil)
parseFormErr := req.ParseForm()
if parseFormErr != nil {
fmt.Println(parseFormErr)
}
res, err := client.Do(req)
if err != nil {
fmt.Println("Failure : ", err)
}
body, _ := ioutil.ReadAll(res.Body)
fmt.Println(res)
fmt.Println(string(body))
}
func main() {
send_proxy()
}
import org.apache.http.HttpHost;
import org.apache.http.HttpResponse;
import org.apache.http.auth.AuthScope;
import org.apache.http.auth.UsernamePasswordCredentials;
import org.apache.http.client.CredentialsProvider;
import org.apache.http.client.HttpClient;
import org.apache.http.client.methods.HttpGet;
import org.apache.http.impl.client.BasicCredentialsProvider;
import org.apache.http.impl.client.HttpClients;
import org.apache.http.impl.conn.BasicHttpClientConnectionManager;
import org.apache.http.util.EntityUtils;
import java.io.IOException;
public class Main {
public static void main(String [] args) throws IOException {
final String PROXY_HOST = "stealthproxy.webscrapingapi.com";
final int PROXY_PORT = 80;
final String PROXY_USER = "<YOUR-PROXY-USERNAME>";
final String PROXY_PASS = "<YOUR-PROXY-PASSWORD>";
final String TARGET_URL = "http://httpbin.org/get";
HttpHost myProxy = new HttpHost(PROXY_HOST, PROXY_PORT);
CredentialsProvider credentialsProvider = new BasicCredentialsProvider();
credentialsProvider.setCredentials(new AuthScope(myProxy)
, new UsernamePasswordCredentials(PROXY_USER,PROXY_PASS));
HttpClient client = HttpClients.custom()
.setConnectionManager(new BasicHttpClientConnectionManager())
.setProxy(myProxy)
.setDefaultCredentialsProvider(credentialsProvider)
.build();
HttpGet request = new HttpGet(TARGET_URL);
HttpResponse response = client.execute(request);
System.out.println(EntityUtils.toString(response.getEntity(), "UTF-8"));
}
}a
using System;
using System.Net;
using System.Net.Http;
using System.Threading.Tasks;
class Program
{
static async Task Main() {
var proxy = new WebProxy("http://stealthproxy.webscrapingapi.com:80")
{
Credentials = new NetworkCredential("<YOUR-PROXY-USERNAME>", "<YOUR-PROXY-PASSWORD>"),
};
var clientHandler = new HttpClientHandler
{
Proxy = proxy,
};
var client = new HttpClient(clientHandler);
var response = await client.GetAsync("http://httpbin.org/get");
Console.WriteLine(await response.Content.ReadAsStringAsync());
}
}
require 'uri'
require 'net/http'
require 'openssl'
proxy_host = "stealthproxy.webscrapingapi.com"
proxy_port = 80
proxy_user = "<YOUR-PROXY-USERNAME>"
proxy_pass = "<YOUR-PROXY-PASSWORD>"
url = URI("http://httpbin.org/get")
proxy = Net::HTTP::Proxy(proxy_host,
proxy_port,
proxy_user,
proxy_pass)
req = Net::HTTP::Get.new(url.path)
response = proxy.start(url.host,url.port) do |http|
http.request(req)
end
puts response.body
Response Example
{
args: {},
headers: {
Accept: 'text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8',
'Accept-Encoding': 'gzip, deflate, br',
Host: 'httpbin.org',
'Upgrade-Insecure-Requests': '1',
'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/101.0.4951.80 Safari/537.36',
'X-Amzn-Trace-Id': 'Root=1-632993e3-29380e237fe8c362301e8a57'
},
origin: '198.46.171.167',
url: 'http://httpbin.org/get'
}
#2: POST Requests
curl -k -x "http://stealthproxy.webscrapingapi.com:80" -U "<YOUR-PROXY-USERNAME>:<YOUR-PROXY-PASSWORD>" -X POST "https://httpbin.org/get" --data '{"foo":"bar"}'
const axios = require('axios');
let data = { 'foo':'bar' }
axios.post('http://httpbin.org/post', data, {
proxy: {
host: 'stealthproxy.webscrapingapi.com',
port: 80,
auth: {
username: '<YOUR-PROXY-USERNAME>',
password: '<YOUR-PROXY-PASSWORD>'
}
}
}).then(function (response) {
console.log(response.data);
}, (err) => {
console.log(err)
})
import requests
USERNAME = '<YOUR-PROXY-USERNAME>'
PASSWORD = '<YOUR-PROXY-PASSWORD>'
TARGET_URL = 'https://httpbin.org/post'
DATA = {"foo":"bar"}
PROXY = {
"https": f"http://{ USERNAME }:{ PASSWORD }@stealthproxy.webscrapingapi.com:80",
}
response = requests.post(
url=TARGET_URL,
data=DATA,
proxies=PROXY,
verify=False
)
print(response.text)
<?php
$data = json_encode(array("foo" => "bar"));
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, 'https://httpbin.org/post');
curl_setopt($ch, CURLOPT_PROXY, 'http://<YOUR-PROXY-USERNAME>:<YOUR-PROXY-PASSWORD>@stealthproxy.webscrapingapi.com:80');
curl_setopt( $ch, CURLOPT_POSTFIELDS, $data);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'POST');
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
$response = curl_exec($ch);
if (!$response) {
die('Error: "'.curl_error($ch).'" - Code: '.curl_errno($ch));
}
echo 'HTTP Status Code: '.curl_getinfo($ch, CURLINFO_HTTP_CODE) . PHP_EOL;
echo 'Response Body: '.$response . PHP_EOL;
curl_close($ch);
?>
package main
import (
"crypto/tls"
"fmt"
"io/ioutil"
"net/http"
"net/url"
"strings"
)
func send_proxy() {
proxyStr := "http://<YOUR-PROXY-USERNAME>:<YOUR-PROXY-PASSWORD>@stealthproxy.webscrapingapi.com:80"
proxyURL, err := url.Parse(proxyStr)
if err != nil {
fmt.Println(err)
}
transport := &http.Transport{
Proxy: http.ProxyURL(proxyURL),
TLSClientConfig: &tls.Config{InsecureSkipVerify: true},
}
client := &http.Client{
Transport: transport,
}
data := url.Values{}
data.Set("foo","bar")
req, err := http.NewRequest("POST", "http://httpbin.org/post", strings.NewReader(data.Encode()))
parseFormErr := req.ParseForm()
if parseFormErr != nil {
fmt.Println(parseFormErr)
}
res, err := client.Do(req)
if err != nil {
fmt.Println("Failure : ", err)
}
body, _ := ioutil.ReadAll(res.Body)
fmt.Println(res)
fmt.Println(string(body))
}
func main() {
send_proxy()
}
import org.apache.http.HttpEntity;
import org.apache.http.HttpHost;
import org.apache.http.HttpResponse;
import org.apache.http.auth.AuthScope;
import org.apache.http.auth.UsernamePasswordCredentials;
import org.apache.http.client.CredentialsProvider;
import org.apache.http.client.HttpClient;
import org.apache.http.client.methods.HttpPost;
import org.apache.http.entity.ContentType;
import org.apache.http.entity.StringEntity;
import org.apache.http.impl.client.BasicCredentialsProvider;
import org.apache.http.impl.client.HttpClients;
import org.apache.http.impl.conn.BasicHttpClientConnectionManager;
import org.apache.http.util.EntityUtils;
import java.io.IOException;
public class Main {
public static void main(String [] args) throws IOException {
final String PROXY_HOST = "stealthproxy.webscrapingapi.com";
final int PROXY_PORT = 80;
final String PROXY_USER = "<YOUR-PROXY-USERNAME>";
final String PROXY_PASS = "<YOUR-PROXY-PASSWORD>";
final String TARGET_URL = "http://httpbin.org/post";
final String BODY = "{\"foo\":\"bar\"}";
HttpHost myProxy = new HttpHost(PROXY_HOST, PROXY_PORT);
CredentialsProvider credentialsProvider = new BasicCredentialsProvider();
credentialsProvider.setCredentials(new AuthScope(myProxy)
, new UsernamePasswordCredentials(PROXY_USER,PROXY_PASS));
HttpClient client = HttpClients.custom()
.setConnectionManager(new BasicHttpClientConnectionManager())
.setProxy(myProxy)
.setDefaultCredentialsProvider(credentialsProvider)
.build();
HttpPost request = new HttpPost(TARGET_URL);
HttpEntity stringEntity = new StringEntity(BODY, ContentType.APPLICATION_JSON);
request.setEntity(stringEntity);
HttpResponse response = client.execute(request);
System.out.println(EntityUtils.toString(response.getEntity(), "UTF-8"));
}
}
using System;
using System.Collections.Generic;
using System.Net;
using System.Net.Http;
using System.Threading.Tasks;
class Program
{
static async Task Main() {
var proxy = new WebProxy("http://stealthproxy.webscrapingapi.com:80")
{
Credentials = new NetworkCredential("<YOUR-PROXY-USERNAME>", "<YOUR-PROXY-PASSWORD>"),
};
var clientHandler = new HttpClientHandler
{
Proxy = proxy,
};
var data = new FormUrlEncodedContent(new[]
{
new KeyValuePair<string, string>("foo", "bar"),
});
var client = new HttpClient(clientHandler);
var response = await client.PostAsync("http://httpbin.org/post", data);
Console.WriteLine(await response.Content.ReadAsStringAsync());
}
}
require 'uri'
require 'net/http'
require 'openssl'
proxy_host = "stealthproxy.webscrapingapi.com"
proxy_port = 80
proxy_user = "<YOUR-PROXY-USERNAME>"
proxy_pass = "<YOUR-PROXY-KEY>"
url = URI("http://httpbin.org/post")
proxy = Net::HTTP::Proxy(proxy_host,
proxy_port,
proxy_user,
proxy_pass)
req = Net::HTTP::Post.new(url.path)
req.set_form_data({'foo' => 'bar'})
response = proxy.start(url.host,url.port) do |http|
http.request(req)
end
puts response.body
Response 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": "28",
"Content-Type": "application/x-www-form-urlencoded",
"Host": "httpbin.org",
"Upgrade-Insecure-Requests": "1",
"User-Agent": "Mozilla/5.0 (Windows NT 6.3; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/101.0.4951.64 Safari/537.36",
"X-Amzn-Trace-Id": "Root=1-631edd38-2bbe74166ca70a5b438fa87f"
},
"json": null,
"origin": "196.244.10.12",
"url": "https://httpbin.org/post"
}a
#3: PUT Requests
curl -k -x "http://stealthproxy.webscrapingapi.com:80" -U "<YOUR-PROXY-USERNAME>:<YOUR-PROXY-PASSWORD>" -X PUT "https://httpbin.org/get" --data '{"foo":"bar"}'
const axios = require('axios');
let data = { 'foo':'bar' }
axios.put('http://httpbin.org/put', data, {
proxy: {
host: 'stealthproxy.webscrapingapi.com',
port: 80,
auth: {
username: '<YOUR-PROXY-USERNAME>',
password: '<YOUR-PROXY-PASSWORD>'
}
}
}).then(function (response) {
console.log(response.data);
}, (err) => {
console.log(err)
})
import requests
USERNAME = '<YOUR-PROXY-USERNAME>'
PASSWORD = '<YOUR-PROXY-PASSWORD>'
TARGET_URL = 'https://httpbin.org/post'
DATA = {"foo":"bar"}
PROXY = {
"https": f"http://{ USERNAME }:{ PASSWORD }@stealthproxy.webscrapingapi.com:80",
}
response = requests.put(
url=TARGET_URL,
data=DATA,
proxies=PROXY,
verify=False
)
print(response.text)
<?php
$data = json_encode(array("foo" => "bar"));
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, 'https://httpbin.org/post');
curl_setopt($ch, CURLOPT_PROXY, 'http://<YOUR-PROXY-USERNAME>:<YOUR-PROXY-PASSWORD>@stealthproxy.webscrapingapi.com:80');
curl_setopt( $ch, CURLOPT_POSTFIELDS, $data);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'POST');
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
$response = curl_exec($ch);
if (!$response) {
die('Error: "'.curl_error($ch).'" - Code: '.curl_errno($ch));
}
echo 'HTTP Status Code: '.curl_getinfo($ch, CURLINFO_HTTP_CODE) . PHP_EOL;
echo 'Response Body: '.$response . PHP_EOL;
curl_close($ch);
?>
package main
import (
"crypto/tls"
"fmt"
"io/ioutil"
"net/http"
"net/url"
"strings"
)
func send_proxy() {
proxyStr := "http://<YOUR-PROXY-USERNAME>:<YOUR-PROXY-PASSWORD>@stealthproxy.webscrapingapi.com:80"
proxyURL, err := url.Parse(proxyStr)
if err != nil {
fmt.Println(err)
}
transport := &http.Transport{
Proxy: http.ProxyURL(proxyURL),
TLSClientConfig: &tls.Config{InsecureSkipVerify: true},
}
client := &http.Client{
Transport: transport,
}
data := url.Values{}
data.Set("foo","bar")
req, err := http.NewRequest("PUT", "http://httpbin.org/post", strings.NewReader(data.Encode()))
parseFormErr := req.ParseForm()
if parseFormErr != nil {
fmt.Println(parseFormErr)
}
res, err := client.Do(req)
if err != nil {
fmt.Println("Failure : ", err)
}
body, _ := ioutil.ReadAll(res.Body)
fmt.Println(res)
fmt.Println(string(body))
}
func main() {
send_proxy()
}
import org.apache.http.HttpEntity;
import org.apache.http.HttpHost;
import org.apache.http.HttpResponse;
import org.apache.http.auth.AuthScope;
import org.apache.http.auth.UsernamePasswordCredentials;
import org.apache.http.client.CredentialsProvider;
import org.apache.http.client.HttpClient;
import org.apache.http.client.methods.HttpPut;
import org.apache.http.entity.ContentType;
import org.apache.http.entity.StringEntity;
import org.apache.http.impl.client.BasicCredentialsProvider;
import org.apache.http.impl.client.HttpClients;
import org.apache.http.impl.conn.BasicHttpClientConnectionManager;
import org.apache.http.util.EntityUtils;
import java.io.IOException;
public class Main {
public static void main(String [] args) throws IOException {
final String PROXY_HOST = "stealthproxy.webscrapingapi.com";
final int PROXY_PORT = 80;
final String PROXY_USER = "<YOUR-PROXY-USERNAME>";
final String PROXY_PASS = "<YOUR-PROXY-PASSWORD>";
final String TARGET_URL = "http://httpbin.org/put";
final String BODY = "{\"foo\":\"bar\"}";
HttpHost myProxy = new HttpHost(PROXY_HOST, PROXY_PORT);
CredentialsProvider credentialsProvider = new BasicCredentialsProvider();
credentialsProvider.setCredentials(new AuthScope(myProxy)
, new UsernamePasswordCredentials(PROXY_USER,PROXY_PASS));
HttpClient client = HttpClients.custom()
.setConnectionManager(new BasicHttpClientConnectionManager())
.setProxy(myProxy)
.setDefaultCredentialsProvider(credentialsProvider)
.build();
HttpPut request = new HttpPut(TARGET_URL);
HttpEntity stringEntity = new StringEntity(BODY, ContentType.APPLICATION_JSON);
request.setEntity(stringEntity);
HttpResponse response = client.execute(request);
System.out.println(EntityUtils.toString(response.getEntity(), "UTF-8"));
}
}
using System;
using System.Collections.Generic;
using System.Net;
using System.Net.Http;
using System.Threading.Tasks;
class Program
{
static async Task Main() {
var proxy = new WebProxy("http://stealthproxy.webscrapingapi.com:80")
{
Credentials = new NetworkCredential("<YOUR-PROXY-USERNAME>", "<YOUR-RPOXY-PASSWORD>"),
};
var clientHandler = new HttpClientHandler
{
Proxy = proxy,
};
var data = new FormUrlEncodedContent(new[]
{
new KeyValuePair<string, string>("foo", "bar"),
});
var client = new HttpClient(clientHandler);
var response = await client.PutAsync("http://httpbin.org/put", data);
Console.WriteLine(await response.Content.ReadAsStringAsync());
}
}
require 'uri'
require 'net/http'
require 'openssl'
proxy_host = "stealthproxy.webscrapingapi.com"
proxy_port = 80
proxy_user = "<YOUR-RPOXY-USERNAME>"
proxy_pass = "<YOUR-PROXY-PASSWORD>"
url = URI("http://httpbin.org/put")
proxy = Net::HTTP::Proxy(proxy_host,
proxy_port,
proxy_user,
proxy_pass)
req = Net::HTTP::Put.new(url.path)
req.set_form_data({'foo' => 'bar'})
response = proxy.start(url.host,url.port) do |http|
http.request(req)
end
puts response.body
Response 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": "28",
"Content-Type": "application/x-www-form-urlencoded",
"Host": "httpbin.org",
"Upgrade-Insecure-Requests": "1",
"User-Agent": "Mozilla/5.0 (Windows NT 6.3; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/101.0.4951.64 Safari/537.36",
"X-Amzn-Trace-Id": "Root=1-631edd38-2bbe74166ca70a5b438fa87f"
},
"json": null,
"origin": "196.244.10.12",
"url": "https://httpbin.org/put"
}
Last updated