虫术 虫术
首页
目录
  • 国内验证码

    • 顶象 DING XIANG
    • 数美 NEXTDATA
    • 易盾 NETEASE YIDUN
    • 极验 GEETEST
    • 阿里云云盾验证码
    • 腾讯天御 T-Sec
    • 小红书 redCaptcha
    • 小盾 XIAODUN
    • 云片 YUNPIAN
    • 三六零天御
    • 螺丝帽 Luosimao
    • Vaptcha
    • V5 验证
    • 凯格 KYGER
    • 友验 FastYotest
  • 国外验证码

    • Cloudflare Turnstile
    • Google reCAPTCHA
    • hCaptcha
    • Arkose Labs FunCAPTCHA
    • DataDome CAPTCHA
    • PerimeterX丨HUMAN Challenge
    • AWS (Amazon) WAF Captcha
    • MTCaptcha
    • Lemin CAPTCHA丨Capy Puzzle
    • Yandex SmartCaptcha
    • mCaptcha
    • KeyCAPTCHA
    • CyberSiARA
    • Friendly Captcha
    • ARCaptcha
    • CaptchaFox
  • 辅助脚本

    • JS Hook
    • Frida API
    • babel
  • 命令查询

    • Linux 命令
    • ADB 命令
    • ARM 指令集
    • Dalvik 指令集
  • 指纹信息

    • CreepJS
    • Fingerprint2
    • 自动化工具检测
  • 加密算法

    • URL
    • Unicode
    • Base64
    • MD5
    • HMAC
    • SHA
    • RSA
    • AES
    • DES
    • 3DES
    • RC4
    • SM
  • 基本请求

    • Python
  • 异步协程

    • asyncio
    • gevent
  • 多线程

    • threading
    • vthread
  • 多进程

    • multiprocessing
  • 自动化框架

    • selenium
    • pyppeteer
    • playwright
    • splash
    • DrissionPage
    • appium
    • airtest
  • 接口编写

    • FastAPI
    • flask
    • express
  • 爬虫框架

    • scrapy
    • feapder
    • pyspider
  • 数据提取

    • re
    • lxml
    • BeautifulSoup
    • pyquery
    • selectolax
  • 数据分析

    • wordcloud
    • jieba
    • pandas
    • NumPy
    • SciPy
  • 制表绘图

    • matplotlib
    • pyecharts
    • plotly
    • seaborn
  • 数据存储

    • 文件存储
    • MySQL
    • MongoDB
    • Redis
    • SQLite
悟空风控
赞助
GitHub (opens new window)
首页
目录
  • 国内验证码

    • 顶象 DING XIANG
    • 数美 NEXTDATA
    • 易盾 NETEASE YIDUN
    • 极验 GEETEST
    • 阿里云云盾验证码
    • 腾讯天御 T-Sec
    • 小红书 redCaptcha
    • 小盾 XIAODUN
    • 云片 YUNPIAN
    • 三六零天御
    • 螺丝帽 Luosimao
    • Vaptcha
    • V5 验证
    • 凯格 KYGER
    • 友验 FastYotest
  • 国外验证码

    • Cloudflare Turnstile
    • Google reCAPTCHA
    • hCaptcha
    • Arkose Labs FunCAPTCHA
    • DataDome CAPTCHA
    • PerimeterX丨HUMAN Challenge
    • AWS (Amazon) WAF Captcha
    • MTCaptcha
    • Lemin CAPTCHA丨Capy Puzzle
    • Yandex SmartCaptcha
    • mCaptcha
    • KeyCAPTCHA
    • CyberSiARA
    • Friendly Captcha
    • ARCaptcha
    • CaptchaFox
  • 辅助脚本

    • JS Hook
    • Frida API
    • babel
  • 命令查询

    • Linux 命令
    • ADB 命令
    • ARM 指令集
    • Dalvik 指令集
  • 指纹信息

    • CreepJS
    • Fingerprint2
    • 自动化工具检测
  • 加密算法

    • URL
    • Unicode
    • Base64
    • MD5
    • HMAC
    • SHA
    • RSA
    • AES
    • DES
    • 3DES
    • RC4
    • SM
  • 基本请求

    • Python
  • 异步协程

    • asyncio
    • gevent
  • 多线程

    • threading
    • vthread
  • 多进程

    • multiprocessing
  • 自动化框架

    • selenium
    • pyppeteer
    • playwright
    • splash
    • DrissionPage
    • appium
    • airtest
  • 接口编写

    • FastAPI
    • flask
    • express
  • 爬虫框架

    • scrapy
    • feapder
    • pyspider
  • 数据提取

    • re
    • lxml
    • BeautifulSoup
    • pyquery
    • selectolax
  • 数据分析

    • wordcloud
    • jieba
    • pandas
    • NumPy
    • SciPy
  • 制表绘图

    • matplotlib
    • pyecharts
    • plotly
    • seaborn
  • 数据存储

    • 文件存储
    • MySQL
    • MongoDB
    • Redis
    • SQLite
悟空风控
赞助
GitHub (opens new window)
bright data bright data

(进入注册为作者充电)

  • 基本请求

    • Python

      • requests
      • urllib
      • aiohttp
      • httpx
      • pyhttpx
      • tls_client
      • curl_cffi
      • requests_go
        • 使用 requests-go
        • 常见错误
        • tls_config 指纹信息
        • ciphers 使用
        • JA3 指纹随机化
      • pycurl
      • websocket
      • pysocks
  • 异步协程

    • asyncio
    • gevent
  • 多线程

    • threading
    • vthread
  • 多进程

    • multiprocessing
目录

requests_go

Python requests_go

requests_go 是一个支持 tls 指纹修改(如ja3)和 http2 的 http 请求库,它基于 requests(python 版) (opens new window) 和 requests(go 版) (opens new window),使用 requests 做为上层请求参数处理库,requests(go版)作为底层进行网络请求。requests_go 使用方法跟 requests 一模一样,与之唯一不同的就是多了一个 tls_config 参数,此参数是用于修改 tls 指纹信息的。

点击查看 官方文档 (opens new window)

# 使用 requests-go

requests-go 使用方法跟 requests 一模一样,与之唯一不同的就是多了一个 tls_config 参数,此参数是用于修改tls指纹信息的。

custom_tls:

import requests_go

url = "https://tls.peet.ws/api/all"
headers = {
    "user-agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/113.0.0.0 Safari/537.36"
}
tls = requests_go.tls_config.TLSConfig()
tls.ja3 = "771,4865-4866-4867-49195-49199-49196-49200-52393-52392-49171-49172-156-157-47-53,16-18-5-27-0-13-11-43-45-35-51-23-10-65281-17513-21,29-23-24,0"
tls.pseudo_header_order = [
    ":method",
    ":authority",
    ":scheme",
    ":path",
]
tls.tls_extensions.cert_compression_algo = ["brotli"]
tls.tls_extensions.supported_signature_algorithms = [
    "ecdsa_secp256r1_sha256",
    "rsa_pss_rsae_sha256",
    "rsa_pkcs1_sha256",
    "ecdsa_secp384r1_sha384",
    "rsa_pss_rsae_sha384",
    "rsa_pkcs1_sha384",
    "rsa_pss_rsae_sha512",
    "rsa_pkcs1_sha512"
]
tls.tls_extensions.supported_versions = [
    "GREASE",
    "1.3",
    "1.2"
]
tls.tls_extensions.psk_key_exchange_modes = [
    "PskModeDHE"
]
tls.tls_extensions.key_share_curves = [
    "GREASE",
    "X25519"
]
tls.http2_settings.settings = {
    "HEADER_TABLE_SIZE": 65536,
    "ENABLE_PUSH": 0,
    "MAX_CONCURRENT_STREAMS": 1000,
    "INITIAL_WINDOW_SIZE": 6291456,
    "MAX_HEADER_LIST_SIZE": 262144
}
tls.http2_settings.settings_order = [
    "HEADER_TABLE_SIZE",
    "ENABLE_PUSH",
    "MAX_CONCURRENT_STREAMS",
    "INITIAL_WINDOW_SIZE",
    "MAX_HEADER_LIST_SIZE"
]
tls.http2_settings.connection_flow = 15663105
response = requests_go.get(url=url, headers=headers, tls_config=tls)
print(response.url)
print(response.text)
print(response.headers)
print(response.cookies)

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58

# 常见错误

  1. 单独设置ja3报404错误的解决方法:默认使用http2,必须搭配pseudo_header_order伪标题顺序去使用,否则会访问失败404,或force_http1强制使用http1(0.3版本会更新)。
  2. 挂上VPN后报EOF错误的解决方法:默认requests-go跟requests一样会去读取系统环境变量中的代理,默认代理会使用https协议,需手动修改proxies的代理为http协议即可。

兼容requests:

import requests_go as requests	# 想要兼容requests改变requests_go的包名为requests即可
1

# tls_config 指纹信息

tls_config指纹信息每项指纹的作用可以参考config.py (opens new window)的源码。

如若不知,可直接使用to_tls_config函数将访问https://tls.peet.ws/api/all (opens new window)后的json结果转换为TLSConfig即可。

import requests_go as requests
from requests_go import tls_config

url = "https://tls.peet.ws/api/all"
tc = {
    ...
}   # tc is browser access https://tls.peet.ws/api/all json result
tls_conf = tls_config.to_tls_config(tc)
response = requests.get(url, tls_config=tls_conf)
print(response.text)

# or

tc = {
	"Ja3": "771,4865-4866-4867-49195-49199-49196-49200-52393-52392-49171-49172-156-157-47-53,0-23-65281-10-11-35-16-5-13-18-51-45-43-27-17513-21,29-23-24,0",
}
response = requests.get(url, tls_config=tc)  # default tls_config is dict class the convert TLSConfig class
# response = requests.get(url, tls_config=tls_config.TLSConfig(config=tc))  # default tls_config is dict class the convert TLSConfig class
print(response.text)

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20

注意:不能自行设置content-length,否则会出现未知错误!

# ciphers 使用

ciphers可以帮助你还原ja3中的CipherSuites部分和charles中的CipherSuites部分,可以快速的查找到自己所需的CipherSuite。

from requests_go.tls_config import ciphers

print(ciphers.cipher_suite_to_decimal("TLS_AES_128_GCM_SHA256"))    # cipher_suite转十进制
# 输出结果: 4865
print(ciphers.decimal_to_cipher_suite(4865))    # 十进制转cipher_suite
# 输出结果: TLS_AES_128_GCM_SHA256

cipher_suites = """
TLS_GREASE 0x4a 0x4a
TLS_AES_128_GCM_SHA256
TLS_AES_256_GCM_SHA384
TLS_CHACHA20_POLY1305_SHA256
TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256
TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256
TLS_ECDHE_ECDSA_WITH_AES_256_GCM_SHA384
TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384
TLS_ECDHE_ECDSA_WITH_CHACHA20_POLY1305_SHA256
TLS_ECDHE_RSA_WITH_CHACHA20_POLY1305_SHA256
TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA
TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA
TLS_RSA_WITH_AES_128_GCM_SHA256
TLS_RSA_WITH_AES_256_GCM_SHA384
TLS_RSA_WITH_AES_128_CBC_SHA
TLS_RSA_WITH_AES_256_CBC_SHA
"""
decimals = ciphers.cipher_suites_to_decimals(cipher_suites)  # cipher_suite列表转十进制
print(decimals)
# 输出结果: [4865, 4866, 4867, 49195, 49199, 49196, 49200, 52393, 52392, 49171, 49172, 156, 157, 47, 53]

print("-".join([str(decimal) for decimal in decimals]))
# 输出结果: 4865-4866-4867-49195-49199-49196-49200-52393-52392-49171-49172-156-157-47-53
print(ciphers.decimals_to_cipher_suites("-".join([str(decimal) for decimal in decimals])))   # 十进制字符串转cipher_suite列表
# 输出结果: ['TLS_AES_128_GCM_SHA256', 'TLS_AES_256_GCM_SHA384', 'TLS_CHACHA20_POLY1305_SHA256', 'TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256', 'TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256', 'TLS_ECDHE_ECDSA_WITH_AES_256_GCM_SHA384', 'TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384', 'TLS_ECDHE_ECDSA_WITH_CHACHA20_POLY1305_SHA256', 'TLS_ECDHE_RSA_WITH_CHACHA20_POLY1305_SHA256', 'TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA', 'TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA', 'TLS_RSA_WITH_AES_128_GCM_SHA256', 'TLS_RSA_WITH_AES_256_GCM_SHA384', 'TLS_RSA_WITH_AES_128_CBC_SHA', 'TLS_RSA_WITH_AES_256_CBC_SHA']
print("\n".join([str(decimal) for decimal in decimals]))
# 输出结果: 
"""
4865
4866
4867
49195
49199
49196
49200
52393
52392
49171
49172
156
157
47
53
"""
print(ciphers.decimals_to_cipher_suites("\n".join([str(decimal) for decimal in decimals]), split_str="\n"))   # split_str分割字符串,默认为-
# 输出结果: ['TLS_AES_128_GCM_SHA256', 'TLS_AES_256_GCM_SHA384', 'TLS_CHACHA20_POLY1305_SHA256', 'TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256', 'TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256', 'TLS_ECDHE_ECDSA_WITH_AES_256_GCM_SHA384', 'TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384', 'TLS_ECDHE_ECDSA_WITH_CHACHA20_POLY1305_SHA256', 'TLS_ECDHE_RSA_WITH_CHACHA20_POLY1305_SHA256', 'TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA', 'TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA', 'TLS_RSA_WITH_AES_128_GCM_SHA256', 'TLS_RSA_WITH_AES_256_GCM_SHA384', 'TLS_RSA_WITH_AES_128_CBC_SHA', 'TLS_RSA_WITH_AES_256_CBC_SHA']

cipher_suites = ciphers.decimals_to_cipher_suites(decimals)  # 十进制列表转cipher_suite列表
print(cipher_suites)
# 输出结果: ['TLS_AES_128_GCM_SHA256', 'TLS_AES_256_GCM_SHA384', 'TLS_CHACHA20_POLY1305_SHA256', 'TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256', 'TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256', 'TLS_ECDHE_ECDSA_WITH_AES_256_GCM_SHA384', 'TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384', 'TLS_ECDHE_ECDSA_WITH_CHACHA20_POLY1305_SHA256', 'TLS_ECDHE_RSA_WITH_CHACHA20_POLY1305_SHA256', 'TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA', 'TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA', 'TLS_RSA_WITH_AES_128_GCM_SHA256', 'TLS_RSA_WITH_AES_256_GCM_SHA384', 'TLS_RSA_WITH_AES_128_CBC_SHA', 'TLS_RSA_WITH_AES_256_CBC_SHA']

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59

# JA3 指纹随机化

现在高版本浏览器都会将ja3的指纹随机化,但是其随机化原理仅仅是对extensions部分进行随机化。

import requests_go

config = {
    ...
}
tls_config = requests_go.tls_config.to_tls_config(config)
tls_config.ja3 = requests_go.tls_config.JA3Random(tls_config.ja3)
for i in range(10):
    print(tls_config.ja3)

# 输出结果:
# 771,4865-4866-4867-49195-49199-49196-49200-52393-52392-49171-49172-156-157-47-53,18-13-21-17513-43-11-0-10-45-27-51-5-65281-35-23-16,29-23-24,0
# 771,4865-4866-4867-49195-49199-49196-49200-52393-52392-49171-49172-156-157-47-53,13-23-18-51-10-11-17513-65281-45-43-16-35-0-5-27-21,29-23-24,0
# 771,4865-4866-4867-49195-49199-49196-49200-52393-52392-49171-49172-156-157-47-53,23-16-17513-18-0-43-10-35-21-5-51-65281-13-45-11-27,29-23-24,0
# 771,4865-4866-4867-49195-49199-49196-49200-52393-52392-49171-49172-156-157-47-53,18-51-43-35-27-23-0-21-17513-13-45-5-11-10-65281-16,29-23-24,0
# 771,4865-4866-4867-49195-49199-49196-49200-52393-52392-49171-49172-156-157-47-53,0-11-21-10-65281-35-16-18-51-23-13-17513-45-27-43-5,29-23-24,0
# 771,4865-4866-4867-49195-49199-49196-49200-52393-52392-49171-49172-156-157-47-53,43-65281-17513-13-35-16-0-51-27-18-21-5-11-23-45-10,29-23-24,0
# 771,4865-4866-4867-49195-49199-49196-49200-52393-52392-49171-49172-156-157-47-53,16-27-11-21-10-5-18-0-35-65281-45-51-13-43-23-17513,29-23-24,0
# 771,4865-4866-4867-49195-49199-49196-49200-52393-52392-49171-49172-156-157-47-53,43-23-21-17513-35-27-0-18-11-5-65281-45-10-16-13-51,29-23-24,0
# 771,4865-4866-4867-49195-49199-49196-49200-52393-52392-49171-49172-156-157-47-53,5-45-65281-43-17513-11-0-10-27-21-13-35-16-51-18-23,29-23-24,0
# 771,4865-4866-4867-49195-49199-49196-49200-52393-52392-49171-49172-156-157-47-53,45-23-27-43-18-21-13-5-65281-11-10-16-35-17513-51-0,29-23-24,0
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
帮助我们改善此页 (opens new window)
上次更新: 2025/04/22, 14:38:07
curl_cffi
pycurl

← curl_cffi pycurl→

ICP 备案 鄂ICP备19003281号-9丨 MPS 公网安备 鄂公网安备42280202422959丨 Theme by Vdoing Theme Vdoing丨 Tencent EdgeOne Tencent EdgeOne丨 51la 网站统计

Copyright © 2023 - 2025 WuKong Security.丨 正在载入网站运行时间...丨
  • 跟随系统
  • 浅色模式
  • 深色模式
  • 阅读模式