We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
以下个人整理,如有错漏欢迎指正,一起讨论让项目发展更好。
@jhao104
http代理和https代理的区别: http/https/socks4/socks5/socks5h/vmess/vless等都是代理服务器提供服务时候与客户端通讯的协议,即cleint <--->proxy server 采用哪种协议。
python的request库中proxies对象其中key包括http/https/socks5等
proxies = { "http": "https://192.168.1.1:8888", "https": "https://127.0.0.1.1:8888", } # http 表示针对访问页面为http协议的页面比如:`http://httpbin.org` 使用 `https://192.168.1.1:8888` 这个代理去访问 # https 表示针对访问https协议的页面比如:`https://baidu.com` 使用 `https://127.0.0.1.1:8888`这个代理去访问 # 并不是指 http协议的代理服务器只能访问http的页面,https协议的代理服务器只能访问https的页面
httpTimeOutValidator
{"http": "http://{proxy}".format(proxy=proxy), "https": "http://{proxy}".format(proxy=proxy)}
httpsTimeOutValidator
{"http": "https://{proxy}".format(proxy=proxy), "https": "https://{proxy}".format(proxy=proxy)}
@ProxyValidator.addHttpValidator def httpTimeOutValidator(proxy): """ http检测超时 """ proxies = {"http": "http://{proxy}".format(proxy=proxy), "https": "https://{proxy}".format(proxy=proxy)} try: r = head(conf.httpUrl, headers=HEADER, proxies=proxies, timeout=conf.verifyTimeout) return True if r.status_code == 200 else False except Exception as e: return False @ProxyValidator.addHttpsValidator def httpsTimeOutValidator(proxy): """https检测超时""" proxies = {"http": "http://{proxy}".format(proxy=proxy), "https": "https://{proxy}".format(proxy=proxy)} try: r = head(conf.httpsUrl, headers=HEADER, proxies=proxies, timeout=conf.verifyTimeout, verify=False) return True if r.status_code == 200 else False except Exception as e: return False
http_r = cls.httpValidator(proxy) https_r = False if not http_r else cls.httpsValidator(proxy)
我的改法如下:具体可以看我fork的仓库
HTTP_URL = "https://www.baidu.com" HTTP_URL_HEADER = {"Server": 'bfe'} # 这里百度自己的server 是bfe具有很强的特征性 HTTPS_URL = "https://www.baidu.com" HTTPS_URL_HEADER = {"Server": 'bfe'} @ProxyValidator.addHttpValidator def httpTimeOutValidator(proxy): """ http检测超时 """ proxies = {"http": "http://{proxy}".format(proxy=proxy), "https": "http://{proxy}".format(proxy=proxy)} try: r = head(conf.httpsUrl, headers=HEADER, proxies=proxies, timeout=conf.verifyTimeout, verify=False) if r.status_code == 200: if conf.httpsUrlHeader and len(conf.httpsUrlHeader) > 0: for key in conf.httpsUrlHeader.keys(): if not r.headers.get(key) or not r.headers.get(key).startswith(conf.httpsUrlHeader.get(key)): return False return True except Exception as e: return False @ProxyValidator.addHttpsValidator def httpsTimeOutValidator(proxy): """https检测超时""" proxies = {"http": "https://{proxy}".format(proxy=proxy), "https": "https://{proxy}".format(proxy=proxy)} try: r = head(conf.httpsUrl, headers=HEADER, proxies=proxies, timeout=conf.verifyTimeout, verify=False) if r.status_code == 200: if conf.httpsUrlHeader and len(conf.httpsUrlHeader) > 0: for key in conf.httpsUrlHeader.keys(): if not r.headers.get(key) or not r.headers.get(key).startswith(conf.httpsUrlHeader.get(key)): return False return True except Exception as e: return False
The text was updated successfully, but these errors were encountered:
好想法
Sorry, something went wrong.
受教,我后面改下
No branches or pull requests
以下个人整理,如有错漏欢迎指正,一起讨论让项目发展更好。
@jhao104
几点知识
http代理和https代理的区别:
http/https/socks4/socks5/socks5h/vmess/vless等都是代理服务器提供服务时候与客户端通讯的协议,即cleint <--->proxy server 采用哪种协议。
python的request库中proxies对象其中key包括http/https/socks5等
代码部分
httpTimeOutValidator
检测,是判断代理是否http协议,那么proxyies 写法应该是{"http": "http://{proxy}".format(proxy=proxy), "https": "http://{proxy}".format(proxy=proxy)}
httpsTimeOutValidator
proxyies 写法应该是{"http": "https://{proxy}".format(proxy=proxy), "https": "https://{proxy}".format(proxy=proxy)}
基于1 ,代理类型是http和https应该是分开处理的,一般来讲代理要么是http类型,要么是https类型,不排除有http/https双协议支持的,不过应该几乎不存在。
我的改法如下:具体可以看我fork的仓库
一些想法
The text was updated successfully, but these errors were encountered: