如何使代理与请求一起工作?

2024-04-19 05:22:08 发布

您现在位置:Python中文网/ 问答频道 /正文

当我试图运行我的代码时,我得到了一个错误,我不明白为什么。救命啊

import requests
import json

proxies = {
  "https": "189.113.217.35:49733",
  "http": "5.252.161.48:8080"
}

r = requests.get("https://groups.roblox.com/v1/groups/1",proxies=proxies)
j = r.json()
print(j)


Tags: 代码httpsimportcomjsonhttpget错误
2条回答

非常简单,我会创建一个会话:

session = requests.Session()

然后,代理命令:

proxies = { 'http': 'http://5.252.161.48:8080', 'https': 'http://5.252.161.48:8080' }

并在会话中插入代理

session.proxies.update(proxies)

我发现,ip地址无法访问代理

相关问题 更多 >