环球宅 Logo环球宅
开发者文档

代码示例

覆盖主流编程语言与工具的代理接入示例,复制即用。

接入信息

代理地址:gate.homeflux.com
HTTP 端口:7777
SOCKS5 端口:7778
认证方式:用户名 / 密码
Python
基础 HTTP 代理python
import requests

proxies = {
    "http":  "http://用户名:密码@gate.homeflux.com:7777",
    "https": "http://用户名:密码@gate.homeflux.com:7777",
}

response = requests.get("https://ip.homeflux.com/json", proxies=proxies)
print(response.json())
轮换 IP(每次请求新 IP)python
import requests
import random
import string

def random_session():
    return ''.join(random.choices(string.ascii_lowercase, k=8))

for i in range(5):
    session = random_session()
    proxy = f"http://用户名-session-{session}:密码@gate.homeflux.com:7777"
    resp = requests.get("https://ip.homeflux.com/json", proxies={"https": proxy})
    print(f"Request {i+1}: {resp.json().get('ip')}")
SOCKS5 代理python
import requests

proxies = {
    "http":  "socks5://用户名:密码@gate.homeflux.com:7778",
    "https": "socks5://用户名:密码@gate.homeflux.com:7778",
}

response = requests.get("https://ip.homeflux.com/json", proxies=proxies)
print(response.json())
Node.js
Axios + HTTP 代理javascript
const axios = require('axios');
const { HttpsProxyAgent } = require('https-proxy-agent');

const agent = new HttpsProxyAgent(
  'http://用户名:密码@gate.homeflux.com:7777'
);

const res = await axios.get('https://ip.homeflux.com/json', {
  httpsAgent: agent,
});
console.log(res.data);
Playwright 代理配置javascript
const { chromium } = require('playwright');

const browser = await chromium.launch({
  proxy: {
    server: 'http://gate.homeflux.com:7777',
    username: '用户名',
    password: '密码',
  },
});

const page = await browser.newPage();
await page.goto('https://ip.homeflux.com/json');
console.log(await page.content());
await browser.close();
Puppeteer 代理配置javascript
const puppeteer = require('puppeteer');

const browser = await puppeteer.launch({
  args: ['--proxy-server=http://gate.homeflux.com:7777'],
});

const page = await browser.newPage();
await page.authenticate({ username: '用户名', password: '密码' });
await page.goto('https://ip.homeflux.com/json');
const content = await page.content();
console.log(content);
await browser.close();
Go
HTTP 代理请求go
package main

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

func main() {
    proxyURL, _ := url.Parse("http://用户名:密码@gate.homeflux.com:7777")
    transport := &http.Transport{Proxy: http.ProxyURL(proxyURL)}
    client := &http.Client{Transport: transport}

    resp, err := client.Get("https://ip.homeflux.com/json")
    if err != nil {
        panic(err)
    }
    defer resp.Body.Close()
    body, _ := io.ReadAll(resp.Body)
    fmt.Println(string(body))
}
Java
HttpClient 代理配置java
import java.net.*;
import java.net.http.*;

public class ProxyExample {
    public static void main(String[] args) throws Exception {
        var proxy = new Proxy(Proxy.Type.HTTP,
            new InetSocketAddress("gate.homeflux.com", 7777));

        var authenticator = new Authenticator() {
            protected PasswordAuthentication getPasswordAuthentication() {
                return new PasswordAuthentication("用户名", "密码".toCharArray());
            }
        };
        Authenticator.setDefault(authenticator);

        var client = HttpClient.newBuilder()
            .proxy(ProxySelector.of((InetSocketAddress) proxy.address()))
            .build();

        var request = HttpRequest.newBuilder()
            .uri(URI.create("https://ip.homeflux.com/json"))
            .build();

        var response = client.send(request, HttpResponse.BodyHandlers.ofString());
        System.out.println(response.body());
    }
}
cURL
HTTP 代理bash
curl -x "http://用户名:密码@gate.homeflux.com:7777" \
  https://ip.homeflux.com/json
SOCKS5 代理bash
curl --socks5 gate.homeflux.com:7778 \
  -U 用户名:密码 \
  https://ip.homeflux.com/json
指定国家(美国)bash
curl -x "http://用户名-country-us:密码@gate.homeflux.com:7777" \
  https://ip.homeflux.com/json
在线客服微信客服Telegram邮件联系