Python3.6使用urllib3报错:request()缺少必填参数'url'求助
Hey there, let's sort out this error quickly! The problem here is a simple syntax mix-up with how you're calling urllib3's request() method.
urllib3's PoolManager.request() function expects the HTTP method (like 'GET' or 'POST') as its first positional argument, followed by the URL you want to fetch. Your current code is passing the URL directly as the first argument, which makes the method think you've skipped the required HTTP method parameter—hence the "missing 'url'" error (it's actually looking for the URL as the second argument, not the first!).
Here's the corrected code:
import urllib3 http = urllib3.PoolManager(10) url = 'https://www.desertessence.com/sitemap.xml' # Add 'GET' as the first argument to specify the HTTP method pagedata = http.request('GET', url).data
If you run into SSL verification issues when fetching the sitemap (some sites have strict SSL settings), you can temporarily disable verification (note: this isn't recommended for production code):
# Disable SSL verification (use cautiously) pagedata = http.request('GET', url, cert_reqs='CERT_NONE').data
Once you update the request() call to include the HTTP method first, the script should successfully pull the sitemap data without that TypeError.
内容的提问来源于stack exchange,提问作者richardaharmon

