注册 登录
编程论坛 Python论坛

爬虫-requests-post

zz12306 发布于 2023-03-18 18:30, 183 次点击
大佬们帮忙看看真的是咋回事啊,,《python3网络爬虫开发实战》52页代码
代码:

import requests
data={'name':'germey','age':'25'}
r=requests.post("https:www.,data=data)
print(r.text)

显示错误代码:
Traceback (most recent call last):
  File "D:\pythonProject1\爬虫\52.py", line 3, in <module>
    r=requests.post("http:www.,data=data)
  File "D:\python310\lib\site-packages\requests\api.py", line 115, in post
    return request("post", url, data=data, json=json, **kwargs)
  File "D:\python310\lib\site-packages\requests\api.py", line 59, in request
    return session.request(method=method, url=url, **kwargs)
  File "D:\python310\lib\site-packages\requests\sessions.py", line 573, in request
    prep = self.prepare_request(req)
  File "D:\python310\lib\site-packages\requests\sessions.py", line 484, in prepare_request
    p.prepare(
  File "D:\python310\lib\site-packages\requests\models.py", line 368, in prepare
    self.prepare_url(url, params)
  File "D:\python310\lib\site-packages\requests\models.py", line 445, in prepare_url
    raise InvalidURL(f"Invalid URL {url!r}: No host supplied")
requests.exceptions.InvalidURL: Invalid URL 'http:www.': No host supplied

2 回复
#2
sheeboard2023-03-18 18:34
https://www. 少了两个斜杠
#3
zz123062023-03-18 18:39
回复 2楼 sheeboard
谢谢大佬
1