wangluozhe / requests-go

go版requests的python版本,支持tls,http2,ja3指纹自定义
MIT License
179 stars 47 forks source link

tls.http2_extensions.connection_flow 不起作用 #1

Closed gospider007 closed 1 year ago

gospider007 commented 1 year ago
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_extensions.settings = {
    "HEADER_TABLE_SIZE": 65536,
    "ENABLE_PUSH": 0,
    "MAX_CONCURRENT_STREAMS": 1000,
    "INITIAL_WINDOW_SIZE": 6291456,
    "MAX_HEADER_LIST_SIZE": 262144
}
tls.http2_extensions.settings_order = [
    "HEADER_TABLE_SIZE",
    "ENABLE_PUSH",
    "MAX_CONCURRENT_STREAMS",
    "INITIAL_WINDOW_SIZE",
    "MAX_HEADER_LIST_SIZE"
]
tls.http2_extensions.connection_flow = 15663106
response = requests_go.get(url=url, headers=headers, tls_config=tls)
print(response.text)
wangluozhe commented 1 year ago

已修复,请更新requests-go,命令:pip install --upgrade requests-go -i https://pypi.python.org/simple

gospider007 commented 1 year ago

更新模块后重新执行程序报错

Traceback (most recent call last):
  File "c:\Users\bai\Desktop\笔记本2\笔记本2\python\ex5.py", line 38, in <module>
    tls.http2_extensions.settings = {
AttributeError: 'TLSConfig' object has no attribute 'http2_extensions'
wangluozhe commented 1 year ago

TLSConfig已经改了http2的属性名了,从http2_extensions改为http2_settings了

gospider007 commented 1 year ago

测试成功