我有一个host:http://retsau.torontomls.net:7890/,我想访问http://retsau.torontomls.net:7890/rets-treb3pv/server/login,我该如何使用Python请求来实现呢?到目前为止,我所有的尝试都失败了。
我还遵循了这里的解决方案- Python Requests - Use navigate site by servers IP,并提出了这个-
response = requests.get(http://206.152.41.279/rets-treb3pv/server/login, headers={'Host': retsau.torontomls.net})
但是这导致了这个错误:requests.exceptions.ConnectionError: HTTPConnectionPool(host='206.152.41.279', port=80): Max retries exceeded with url: /rets-treb3pv/server/login (Caused by NewConnectionError('<urllib3.connection.HTTPConnection object at 0x10a4f6d84>: Failed to establish a new connection: [Errno 60] Operation timed out',))
有趣的是,在Postman上一切似乎都运行得很好,我可以访问该服务器上的各种URL,从登录到搜索某些东西。
发布于 2018-12-08 03:42:39
您在get调用的URL中遗漏了端口号(7890):
response = requests.get('http://206.152.41.279:7890/rets-treb3pv/server/login', headers={'Host': 'retsau.torontomls.net'})
# ^^^^ Add this此外,除非您确实有通过IP地址访问站点的特定原因,否则将完全限定域名放在URL中而不是Host报头中会更有意义:
response = requests.get('http://retsau.torontomls.net:7890/rets-treb3pv/server/login')https://stackoverflow.com/questions/53675604
复制相似问题