coder-hxl / airbnb-api

Airbnb-API 是基于 NodeJS、TypeScript 、Koa、MySQL、x-crawl 等技术实现的 Airbnb API 。拥有房源搜索、地区房源、更多地区房源、房源详情、个人信息的 API ,采用 REST 设计风格。
http://47.113.218.204:9001
2 stars 1 forks source link

使用python requestes访问API出现错误:InvalidSchema: No connection adapters were found for 'localhost:9001/api/user' #3

Open wwx0622 opened 1 week ago

wwx0622 commented 1 week ago

pnpm运行成功: image 数据库导入成功: image 数据库示例: image env: image python请求: image python报错信息:

InvalidSchema Traceback (most recent call last) Cell In[2], line 8 5 payload = "{\r\n \"name\": \"admin\",\r\n \"password\": \"admin\",\r\n \"cellphone\": 13680666666,\r\n \"introduce\": null,\r\n \"avatar_url\": null\r\n}" 6 headers = {} ----> 8 response = requests.request("POST", url, headers=headers, data=payload) 10 print(response.text)

File D:\ProgramData\miniconda3\Lib\site-packages\requests\api.py:59, in request(method, url, kwargs) 55 # By using the 'with' statement we are sure the session is closed, thus we 56 # avoid leaving sockets open which can trigger a ResourceWarning in some 57 # cases, and look like a memory leak in others. 58 with sessions.Session() as session: ---> 59 return session.request(method=method, url=url, kwargs)

File D:\ProgramData\miniconda3\Lib\site-packages\requests\sessions.py:589, in Session.request(self, method, url, params, data, headers, cookies, files, auth, timeout, allow_redirects, proxies, hooks, stream, verify, cert, json) 584 send_kwargs = { 585 "timeout": timeout, 586 "allow_redirects": allow_redirects, 587 } 588 send_kwargs.update(settings) --> 589 resp = self.send(prep, **send_kwargs) 591 return resp

File D:\ProgramData\miniconda3\Lib\site-packages\requests\sessions.py:697, in Session.send(self, request, **kwargs) 694 hooks = request.hooks 696 # Get the appropriate adapter to use --> 697 adapter = self.get_adapter(url=request.url) 699 # Start time (approximately) of the request 700 start = preferred_clock()

File D:\ProgramData\miniconda3\Lib\site-packages\requests\sessions.py:792, in Session.get_adapter(self, url) 789 return adapter 791 # Nothing matches :-/ --> 792 raise InvalidSchema(f"No connection adapters were found for {url!r}") InvalidSchema: No connection adapters were found for 'localhost:9001/api/user'

版本信息: win10 mysql: 8 powershell: 7.4 Python 3.12.4 | packaged by Anaconda, Inc. | (main, Jun 18 2024, 15:03:56) [MSC v.1929 64 bit (AMD64)] requests 2.32.3

补充说明: 没有前后端经验,请问这个是什么问题,需要怎么解决,怎么排查?

coder-hxl commented 6 days ago

用其他方式请求也是有问题不,比如请求其他接口或者用 Postman 试试