注册
登录
代理IP知识 / 内容详情
使用代理IP请求https网站时应该怎么写
站大爷 官方 2021-11-29 14:52:28

很多人在使用代理IP访问https网站时,往往会遇到很多错误,我们一起来看看,使用代理IP访问https网站时应该怎么写代码。

使用代理IP请求https网站时应该怎么写


有些用户没有区分访问http网站和https网站的使用方法,统一写成:

######
proxies={
       'http':'http://ip:port'
    }
resp=request.get(url,proxies=proxies)

结果自然是报错了,因为使用的协议不一样。


有些用户有区分访问http网站和https网站的使用方法,是这样写的:

######
proxies={
       'http':'http://ip:port',
       'https':'https://ip:port'
    }
resp=request.get(url,proxies=proxies)

结果还是报错了,这是为什么呢?正确的写法是这样的:

######
proxies={
       'http':'http://ip:port',
       'https':'http://ip:port'
    }
resp=request.get(url,proxies=proxies)


立即注册站大爷用户,免费试用全部产品
立即注册站大爷用户,免费试用全部产品