问题是你正在通过考试
args
requests.post
作为url参数。请求验证您提供给的url
.post()
是有效的,并且url以
{'marketplace': ...}
显然是无效的url。
这部分代码:
response = requests.post(
url=args,
json={
'url': url
}, timeout=60
)
以及
args = query_parser.parse_args()
当您要求源代码来帮助您学习时,这是一段代码,您可以在源代码中找到url开头的请求检查适配器
here
:
def get_adapter(self, url):
"""
Returns the appropriate connection adapter for the given URL.
:rtype: requests.adapters.BaseAdapter
"""
for (prefix, adapter) in self.adapters.items():
if url.lower().startswith(prefix.lower()):
return adapter
# Nothing matches :-/
raise InvalidSchema("No connection adapters were found for '%s'" % url)
这个
self.adapters.items()
用于检查url的来源
here
# Default connection adapters.
self.adapters = OrderedDict()
self.mount('https://', HTTPAdapter())
self.mount('http://', HTTPAdapter())
mount()
方法实际上将预期的url前缀映射到
self.adapters
口述。