韩だ霜 2021-06-03 15:29 采纳率: 50%
浏览 311
已采纳

Python 运行request.get报错

Traceback (most recent call last):
  File "C:/Users/Administrator/PycharmProjects/untitled/request.py", line 5, in <module>
    requests.post('www.baidu.com')
  File "D:\python\lib\site-packages\requests\api.py", line 119, in post
    return request('post', url, data=data, json=json, **kwargs)
  File "D:\python\lib\site-packages\requests\api.py", line 61, in request
    return session.request(method=method, url=url, **kwargs)
  File "D:\python\lib\site-packages\requests\sessions.py", line 528, in request
    prep = self.prepare_request(req)
  File "D:\python\lib\site-packages\requests\sessions.py", line 466, in prepare_request
    hooks=merge_hooks(request.hooks, self.hooks),
  File "D:\python\lib\site-packages\requests\models.py", line 316, in prepare
    self.prepare_url(url, params)
  File "D:\python\lib\site-packages\requests\models.py", line 390, in prepare_url
    raise MissingSchema(error)
requests.exceptions.MissingSchema: Invalid URL 'www.baidu.com': No schema supplied. Perhaps you meant http://www.baidu.com?

  • 写回答

4条回答 默认 最新

  • CSDN专家-黄老师 2021-06-03 15:45
    关注
    import requests
    r = requests.post('https://www.baidu.com/')
    print(r.text)

    你post的url要带http或https,要完整的url地址

    如果对你有帮助,可以点击我这个回答右上方的【采纳】按钮,给我个采纳吗,谢谢

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(3条)

报告相同问题?

悬赏问题

  • ¥15 工创大赛太阳能电动车项目零基础要学什么
  • ¥20 limma多组间分析最终p值只有一个
  • ¥15 nopCommerce开发问题
  • ¥15 torch.multiprocessing.spawn.ProcessExitedException: process 1 terminated with signal SIGKILL
  • ¥15 QuartusⅡ15.0编译项目后,output_files中的.jdi、.sld、.sof不更新怎么解决
  • ¥15 pycharm输出和导师的一样,但是标红
  • ¥15 想问问富文本拿到的html怎么转成docx的
  • ¥15 我看了您的文章,遇到了个问题。
  • ¥15 GitHubssh虚拟机连接不上
  • ¥15 装完kali之后下载Google输入法 重启电脑后出现以下状况 且退不出去 桌面消失 反复重启没用