wangluozhe / requests-go

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

访问接口出现错误unexpected EOF #3

Closed gospider007 closed 1 year ago

gospider007 commented 1 year ago
import requests_go
url = "https://tools.scrapfly.io/api/info/ip"
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"
response = requests_go.get(url=url, headers=headers, tls_config=tls)
print(response.text)
requests_go.tls_client.exceptions.TLSClientExeption: [Errno requests_go error:] {"err": "Get "https://tools.scrapfly.io/api/info/ip": unexpected EOF"}
wangluozhe commented 1 year ago

你又忘记设置伪标头顺序了

wangluozhe commented 1 year ago
import requests_go

url = "https://tools.scrapfly.io/api/info/ip"
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()
proxies = {
    "http": None,
    "https": None,
}
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"
]
response = requests_go.get(url=url, headers=headers, proxies=proxies, tls_config=tls)
print(response.text)
imdly2022 commented 1 year ago

import requests_go url = "https://tools.scrapfly.io/api/info/ip" 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() proxies = { "http": None, "https": None, } 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" ] response = requests_go.get(url=url, headers=headers, tls_config=tls) print(response.text) 也是这个错误 RequestsDependencyWarning: urllib3 (1.26.12) or chardet (None)/charset_normalizer (3.1.0) doesn't match a supported version!

wangluozhe commented 1 year ago

RequestsDependencyWarning: urllib3 (1.26.12) or chardet (None)/charset_normalizer (3.1.0) doesn't match a supported version! 这个不是错误,这个是提醒,warning和error得分清楚

imdly2022 commented 1 year ago

requests_go.tls_client.exceptions.TLSClientExeption: [Errno requests_go error:] {"err": "Get "https://tools.scrapfly.io/api/info/ip": EOF"} 这个

wangluozhe commented 1 year ago

可能是代理的问题,你可以调试看看,代理应该是https://127.0.0.1:xxxx,但是实际上你的本地代理不支持https协议,应改为http协议即http://127.0.0.1:xxxx,这个是因为requests会读取系统环境变量中的代理,如果你不会调试可以尝试把代理关闭后访问。

gospider007 commented 1 year ago

你又忘记设置伪标头顺序了

ja3 必须要设置伪标头吗,建议在文档上标注下

wangluozhe commented 1 year ago

你又忘记设置伪标头顺序了

ja3 必须要设置伪标头吗,建议在文档上标注下

这个是使用http2必须设置的,我只是给忘记添加默认值了,你可以使用tls.force_http1 = True强制使用http1去访问,或者自己添加一下默认值,我下个版本将会更新他。

gospider007 commented 1 year ago

ok