다중 언어로 프록시 목록을 가져오는 방법은 무엇입니까?
26142 단어 programmingproxylist
1. 계정 프로필에서 API 키 가져오기
2. 요청하기:**
// 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)
// call by Curl
shell> curl https://api.pzzqz.com/api/v1.0/proxy/list/ \
--header "X-Api-Key: <API-KEY-HERE>"
// 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))
}
// 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
// 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();
}
}
}
// 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)
// 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();
// 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";
}
// 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;
}
// 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
Reference
이 문제에 관하여(다중 언어로 프록시 목록을 가져오는 방법은 무엇입니까?), 우리는 이곳에서 더 많은 자료를 발견하고 링크를 클릭하여 보았다 https://dev.to/jwdeaa/how-to-fetch-proxy-list-with-multi-language-4f50텍스트를 자유롭게 공유하거나 복사할 수 있습니다.하지만 이 문서의 URL은 참조 URL로 남겨 두십시오.
우수한 개발자 콘텐츠 발견에 전념 (Collection and Share based on the CC Protocol.)