首页 > 其他分享 >requests 开启charles代理报错

requests 开启charles代理报错

时间:2024-06-13 16:57:31浏览次数:12  
标签:winreg http charles proxyServer 报错 registry address requests proxies

当前报错urllib3 版本: 1.26.7

解决代理报错的几种方式:

  • 配置代理请求
proxies = {
        'http': 'http://127.0.0.1:8888',
        'https': 'http://127.0.0.1:8888'
    }
data = requests.post(url, json=body, headers=headers, verify=False, proxies=proxies)
# 注意 https 后面值的协议也是http或者不要协议

  • 打补丁: address = '%s://%s' % (protocol, address) 改成了 address = '%s' % (address)
  def my_getproxies_registry():
    """Return a dictionary of scheme -> proxy server URL mappings.

    Win32 uses the registry to store proxies.

    """
    proxies = {}
    try:
        import winreg
    except ImportError:
        # Std module, so should be around - but you never know!
        return proxies
    try:
        internetSettings = winreg.OpenKey(winreg.HKEY_CURRENT_USER,
                                          r'Software\Microsoft\Windows\CurrentVersion\Internet Settings')
        proxyEnable = winreg.QueryValueEx(internetSettings,
                                          'ProxyEnable')[0]
        if proxyEnable:
            # Returned as Unicode but problems if not converted to ASCII
            proxyServer = str(winreg.QueryValueEx(internetSettings,
                                                  'ProxyServer')[0])
            if '=' in proxyServer:
                # Per-protocol settings
                for p in proxyServer.split(';'):
                    protocol, address = p.split('=', 1)
                    # See if address has a type:// prefix
                    if not re.match('(?:[^/:]+)://', address):
                        address = '%s' % (address)
                    proxies[protocol] = address
            else:
                # Use one setting for all protocols
                if proxyServer[:5] == 'http:':
                    proxies['http'] = proxyServer
                else:
                    proxies['http'] = 'http://%s' % proxyServer
                    proxies['https'] = 'https://%s' % proxyServer
                    proxies['ftp'] = 'ftp://%s' % proxyServer
        internetSettings.Close()
    except (OSError, ValueError, TypeError):
        # Either registry key not found etc, or the value in an
        # unexpected format.
        # proxies already set up to be empty so nothing to do
        pass
    return proxies
if os.name == 'nt':
    from urllib import request
    request.getproxies_registry = my_getproxies_registry
  • 降级urllib3: pip3 install urllib3==1.23

标签:winreg,http,charles,proxyServer,报错,registry,address,requests,proxies
From: https://www.cnblogs.com/wanderingfish/p/18246242

相关文章

  • Let's Encrypt续费证书异常报错解决
    Let'sEncrypt续费证书异常报错解决在续费免费证书时出现错误,这里小记一下。现象#certbotcertonly--webroot-w/usr/share/nginx/html-dgh.wqyfchina.comSavingdebuglogto/var/log/letsencrypt/letsencrypt.logRequestingacertificateforgh.wqyfchina.comCer......
  • Oracle报错:“Error in invoking target ‘agent nmhs’ of makefile...”
    Oracle报错:“Errorininvokingtarget‘agentnmhs’ofmakefile...”  前言:Oracle在安装过程中的报错一定要重视,这决定你后续是否能完成安装以及是否能使用。我这边会陆续汇总一些报错现象以及解决方案共享。##InstallProduct86%报错信息:“Errorininvokingtarget'......
  • 报错:ResizeObserver loop limit exceeded的处理方法(学习自用)
    报错:ResizeObserverlooplimitexceeded处理方法:在main.js添加://从elementui中引出TableimportElementUI,{Table}from'element-ui'//处理table宽度报错的问题constfixElTableErr=table=>{constoldResizeListener=table.methods.resizeListenertabl......
  • 【jmeter】ubuntu分布式jmeter报错:java.rmi.ConnectException: Connection refused to
    一、场景   由于高并发测试,服务器资源不够用,所以需要使用jmeter分布式进行测试,但是测试过程中报错:java.rmi.ConnectException:Connectionrefusedtohost:127.0.1.1;  二、问题原因   就是hostname-i如果返回的是127.0.1.1 三、处理方法   修改hostna......
  • nodejs下载依赖npm install报错
    npminstall报错,解决记录_npmwarnusing--forcerecommendedprotectionsdis-CSDN博客先切换镜像源,然后清理缓存,在使用npm命令注意前面可能爆粗哦的原因大概率是权限问题,所以采用这种解决方式加上面合体:解决:安装vueCLI不成功时,执行npmcleancache-force清除缓存命令无效_n......
  • 解决报错 cuDNN error: CUDNN_STATUS_NOT_SUPPORTED. This error may appear if you p
      训练模型出现报错cuDNNerror: CUDNN_STATUS_NOT_SUPPORTED.Thiserrormayappearifyoupassedinanon-contiguousinput.1.尝试了对可能的tensor添加.contiguous()函数,不能解决问题,排除。2.尝试将batch_size=12减小到10,不再报错,但实验要求不能减小batch_s......
  • gcc编译时报错 fatal error: stdio.h: 没有那个文件或目录
    在kylinV10中使用GCC编译代码时遇到如下问题:首先确认了,自己单词没有拼写错。然后再检查GCC的版本,确实没问题。没有标准的头文件需要安装build-essential来解决。需要安装build-essential。执行以下命令:sudoapt-getinstallbuild-essential如无兼容版本可使用可使用ap......
  • Django学习项目-learning log报错合集(2)
    样式篇stackpath.bootstrapcdn.com/bootstrap/3.4.1/css/bootstrap.min.css:1  Failedtoloadresource:net::ERR_CONNECTION_TIMED_OUTdjango-bootstrap3样式无效按这篇文章进行修改......
  • 会声会影启动报错:找不到mfc110.dll文件的全面解决策略
    在使用会声会影进行视频编辑时,遇到“丢失mfc110.dll”错误提示,无疑会给创作过程带来不小的困扰。这个错误通常意味着系统中缺少了一个重要的动态链接库文件,而mfc110.dll是MicrosoftVisualC++RedistributablePackage的一部分,对于运行许多基于VisualC++开发的应用程序至关重......
  • A Twisted Path to Renown联机报错/无法联机的解决方法
    成名之路/ATwistedPathtoRenown这款游戏的游戏背景是美国西部,包含了PvE、PvP成分,并且比较有意思的一点是,由于成名之路旨在还原年代感和真实感,所以玩家基本上没有全自动的武器道具或者能连发的,基本就是单发武器,也有弓箭可以选择。这款游戏也是比较像猎杀对决和塔科夫,目前游......