TypeError: request() missing 1 required positional argument: 'url' in urllib3
TypeError: request() missing 1 required positional argument: 'url' in urllib3
我正在深入研究 Python 并且正在浏览 urllib3 的文档。尝试了 运行 代码,但似乎没有按预期方式工作。
我的密码是
import urllib3
t = urllib3.PoolManager
test = t.request('GET', 'https://shadowhosting.net/')
print(test.data)
我得到的错误是
TypeError: request() missing 1 required positional argument: 'url'
我试过换地方但还是不行。我正在关注文档的开头(用户指南)
供参考 - https://urllib3.readthedocs.io/en/latest/user-guide.html
打错了,忘记了创建对象的括号:
t = urllib3.PoolManager()
添加它们,它将像魔术一样工作:
import urllib3
t = urllib3.PoolManager()
test = t.request('GET', 'https://shadowhosting.net/')
print(test.data)
如果您想向 URL 发出 GET
请求,那么您可以使用 requests
模块
import requests
response = requests.get('https://shadowhosting.net/')
print(response.text)
https://urllib3.readthedocs.io/en/latest/user-guide.html 的文档说:
import urllib3
http = urllib3.PoolManager() //You were missing this paranthesis
r = http.request('GET', 'http://httpbin.org/robots.txt')
或 POST 请求
r = http.request('POST','http://httpbin.org/post', fields={'hello': 'world'})
我正在深入研究 Python 并且正在浏览 urllib3 的文档。尝试了 运行 代码,但似乎没有按预期方式工作。 我的密码是
import urllib3
t = urllib3.PoolManager
test = t.request('GET', 'https://shadowhosting.net/')
print(test.data)
我得到的错误是
TypeError: request() missing 1 required positional argument: 'url'
我试过换地方但还是不行。我正在关注文档的开头(用户指南) 供参考 - https://urllib3.readthedocs.io/en/latest/user-guide.html
打错了,忘记了创建对象的括号:
t = urllib3.PoolManager()
添加它们,它将像魔术一样工作:
import urllib3
t = urllib3.PoolManager()
test = t.request('GET', 'https://shadowhosting.net/')
print(test.data)
如果您想向 URL 发出 GET
请求,那么您可以使用 requests
模块
import requests
response = requests.get('https://shadowhosting.net/')
print(response.text)
https://urllib3.readthedocs.io/en/latest/user-guide.html 的文档说:
import urllib3
http = urllib3.PoolManager() //You were missing this paranthesis
r = http.request('GET', 'http://httpbin.org/robots.txt')
或 POST 请求
r = http.request('POST','http://httpbin.org/post', fields={'hello': 'world'})