自定义状态代码

如果请求返回 2xx 或 4xx 范围内的状态代码,则认为请求成功。但是,在某些情况下,网站可能会提供必要的内容以及非标准 HTTPS 状态代码。如果你的任何目标表现出此行为,你可以选择指定哪些状态代码是可接受的且与你的需求相关。

curl -k -v -x unblock.smartdaili-china.com:60000 \
-U "USERNAME:PASSWORD" "https://ip.smartdaili-china.com/" \
-H "X-SU-Status-Code: 503, 501"
import requests

proxies = {
    'http': 'http://USERNAME:[email protected]:60000',
    'https': 'http://USERNAME:[email protected]:60000'
}

headers= {
   'X-SU-Status-Code': '503, 501'
}

response = requests.request(
    'GET',
    'https://ip.smartproxy.com/',
    verify=False,
    proxies=proxies,
    headers=headers
)

print(response.text)

import fetch from 'node-fetch';
import createHttpsProxyAgent from 'https-proxy-agent'

const username = 'YOUR_USERNAME';
const password = 'YOUR_PASSWORD';

const agent = createHttpsProxyAgent(
  `http://${username}:${password}@unblock.smartdaili-china.com:60000`
);

process.env['NODE_TLS_REJECT_UNAUTHORIZED'] = 0;

const headers = {
 	'X-SU-Status-Code': '503, 501'
}

const response = await fetch('https://ip.smartproxy.com/', {
  method: 'get',
  headers: headers,
  agent: agent
});

console.log(await response.text());