DEV Community

loading...

how to fetch proxy list with multi language?

jwdeaa profile image jwdeaa ・3 min read

Proxy list website: https://pzzqz.com/

1. Get your api key from account profile

Alt Text

2. Make a request:**

// call by Python

import requests

headers = {
    "X-Api-Key": "<API-KEY-HERE>"
}
url = 'https://api.pzzqz.com/api/v1.0/proxy/list/'
resp = requests.get(url, headers=headers)
json_data = resp.json()

for proxy in json_data['data']:
    print(proxy)
Enter fullscreen mode Exit fullscreen mode

// call by Curl

shell> curl https://api.pzzqz.com/api/v1.0/proxy/list/ \
          --header "X-Api-Key: <API-KEY-HERE>"
Enter fullscreen mode Exit fullscreen mode

// call by Golang

package main

import (
    "fmt"
    "io/ioutil"
    "net/http"
)

func main() {
    url := "https://api.pzzqz.com/api/v1.0/proxy/list/"
    req, _ := http.NewRequest("GET", url, nil)
    req.Header.Add("X-Api-Key", "<API-KEY-HERE>")
    res, _ := http.DefaultClient.Do(req)
    defer res.Body.Close()
    body, _ := ioutil.ReadAll(res.Body)
    //fmt.Println(res)
    fmt.Println(string(body))
}
Enter fullscreen mode Exit fullscreen mode

// call by Groovy

def connection = new URL( "https://api.pzzqz.com/api/v1.0/proxy/list/")
    .openConnection() as HttpURLConnection

connection.setRequestProperty( 'X-Api-Key', '<API-KEY-HERE>' )
connection.setRequestProperty( 'Accept', 'application/json' )

println connection.responseCode
println connection.inputStream.text
Enter fullscreen mode Exit fullscreen mode

// call by Java

import java.io.BufferedReader;
import java.io.DataOutputStream;
import java.io.IOException;
import java.io.InputStreamReader;
import java.net.HttpURLConnection;
import java.net.URL;
import java.nio.charset.StandardCharsets;

public class JavaGetRequest {
  private static HttpURLConnection con;
  public static void main(String[] args) throws IOException {
    var url = "https://api.pzzqz.com/api/v1.0/proxy/list/";
    try {
      var myurl = new URL(url);
      con = (HttpURLConnection) myurl.openConnection();
      con.setDoOutput(true);
      con.setRequestMethod("GET");
      con.setRequestProperty("X-Api-Key", "<API-KEY-HERE>");
      con.setRequestProperty("Content-Type", "application/json");
      StringBuilder content;
      try (var br = new BufferedReader(
        new InputStreamReader(con.getInputStream()))) {
        String line;
        content = new StringBuilder();
        while ((line = br.readLine()) != null) {
          content.append(line);
          content.append(System.lineSeparator());
        }
      }
      System.out.println(content.toString());
    } finally {
      con.disconnect();
    }
  }
}
Enter fullscreen mode Exit fullscreen mode

// call by Lua

local http = require("socket.http")
local ltn12 = require("ltn12")

function http.get(u)
  local resp_body = {}
  local res, code, headers = http.request {
    url = u,
    headers = {
      ["Content-Type"] = "application/json";
      ["X-Api-Key"] = "<API-KEY-HERE>"
    },
    sink = ltn12.sink.table(resp_body)
  }
  return res, code, headers, table.concat(resp_body)
end

function get_url(url)
  res, code, headers, resp_body = http.get(url)
  if code ~= 200 then
    print("ErrorCode: " .. code)
    return
  else
    return resp_body
  end
end

url = "https://api.pzzqz.com/api/v1.0/proxy/list/"
resp = get_url(url)
print(resp)
Enter fullscreen mode Exit fullscreen mode

// call by Nodejs

var http = require("https");
var options = {
    "method": "GET",
    "hostname": "api.pzzqz.com",
    "port": null,
    "path": "/api/v1.0/proxy/list/",
    "headers": {
        "X-Api-Key": "<API-KEY-HERE>"
    }
};
var req = http.request(options, function (res) {
    var chunks = [];
    res.on("data", function (chunk) {
        chunks.push(chunk);
    });
    res.on("end", function () {
        var body = Buffer.concat(chunks);
        console.log(body.toString());
    });
});

req.end();
Enter fullscreen mode Exit fullscreen mode

// call by Perl

use strict;
use warnings;
use LWP::UserAgent;

my $ua = LWP::UserAgent->new;
my $url = 'https://api.pzzqz.com/api/v1.0/proxy/list/';
my $header = ['Content-Type' => 'application/json; charset=UTF-8', 'X-Api-Key' => '<API-KEY-HERE>'];
$ua->agent("MyAgent/0.1");
my $req = HTTP::Request->new('GET', $url, $header);
$req->content_type('application/json');
my $res = $ua->request($req);

if ($res->is_success) {
    print $res->content;
} else {
    print $res->status_line, "n";
}
Enter fullscreen mode Exit fullscreen mode

// call by PHP

<?php
$curl = curl_init();
curl_setopt_array($curl, array(
    CURLOPT_URL => "https://api.pzzqz.com/api/v1.0/proxy/list/",
    CURLOPT_RETURNTRANSFER => true,
    CURLOPT_ENCODING => "",
    CURLOPT_MAXREDIRS => 10,
    CURLOPT_TIMEOUT => 30,
    CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
    CURLOPT_CUSTOMREQUEST => "GET",
    CURLOPT_HTTPHEADER => array(
        "content-type: application/json",
        "X-Api-Key: <API-KEY-HERE>"
    ),
));
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
    echo "cURL Error #:" . $err;
} else {
    echo $response;
}
Enter fullscreen mode Exit fullscreen mode

// call by Ruby

require 'uri'
require 'net/http'

url = URI("https://api.pzzqz.com/api/v1.0/proxy/list/")

http = Net::HTTP.new(url.host, url.port)

request = Net::HTTP::Get.new(url)
request["X-Api-Key"] = '<API-KEY-HERE>'

response = http.request(request)
puts response.read_body
Enter fullscreen mode Exit fullscreen mode

Discussion (0)

pic
Editor guide