吾爱破解 - 52pojie.cn

 找回密码
 注册[Register]

QQ登录

只需一步,快速开始

查看: 1113|回复: 7
收起左侧

[求助] 求助:找不到错误点了。 跑不起来

[复制链接]
zqlcpu 发表于 2022-5-29 10:25
import requests


url = "https://movie.douban.com/j/chart/top_list"

# 重新封装参数

param = {

"type": "24",
"interval_id": "100:90",
"action": " ",
"start": 0,
"limit": 20,

    }
header = {
    "User-Agent":" Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/102.0.5005.62 Safari/537.36"
    }

resp = requests.get(url=url, params=param, headers=header)


print(resp.text)

发帖前要善用论坛搜索功能,那里可能会有你要找的答案或者已经有人发布过相同内容了,请勿重复发帖。

 楼主| zqlcpu 发表于 2022-5-29 10:26
错误信息
Python 3.11.0a7 (main, Apr  5 2022, 21:27:39) [MSC v.1929 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license()" for more information.

==================== RESTART: C:/Users/zqlcpu/Desktop/3.0.py ===================
Traceback (most recent call last):
  File "C:/Users/zqlcpu/Desktop/3.0.py", line 21, in <module>
    resp = requests.get(url=url, params=param, headers=header)
  File "E:\python3.10.4\Lib\site-packages\requests\api.py", line 75, in get
    return request('get', url, params=params, **kwargs)
  File "E:\python3.10.4\Lib\site-packages\requests\api.py", line 61, in request
    return session.request(method=method, url=url, **kwargs)
  File "E:\python3.10.4\Lib\site-packages\requests\sessions.py", line 515, in request
    prep = self.prepare_request(req)
  File "E:\python3.10.4\Lib\site-packages\requests\sessions.py", line 443, in prepare_request
    p.prepare(
  File "E:\python3.10.4\Lib\site-packages\requests\models.py", line 319, in prepare
    self.prepare_headers(headers)
  File "E:\python3.10.4\Lib\site-packages\requests\models.py", line 453, in prepare_headers
    check_header_validity(header)
  File "E:\python3.10.4\Lib\site-packages\requests\utils.py", line 1025, in check_header_validity
    raise InvalidHeader("Invalid return character or leading space in header: %s" % name)
requests.exceptions.InvalidHeader: Invalid return character or leading space in header: User-Agent
话痨司机啊 发表于 2022-5-29 10:30
佳人的泪 发表于 2022-5-29 10:30
 楼主| zqlcpu 发表于 2022-5-29 10:39
非常感谢。
平淡最真 发表于 2022-5-29 10:42

Invalid return character or leading space in header: User-Agent
标头中的返回字符或前导空格无效:User Agent

百度翻译的结果
我是不会改名的 发表于 2022-5-29 10:45
https://curlconverter.com/
你值得拥有

免费评分

参与人数 1吾爱币 +1 收起 理由
冥界3大法王 + 1 良心工程。。。

查看全部评分

fy5377 发表于 2022-5-29 10:46
也在刚开始学习
您需要登录后才可以回帖 登录 | 注册[Register]

本版积分规则

返回列表

RSS订阅|小黑屋|处罚记录|联系我们|吾爱破解 - LCG - LSG ( 京ICP备16042023号 | 京公网安备 11010502030087号 )

GMT+8, 2024-11-25 11:39

Powered by Discuz!

Copyright © 2001-2020, Tencent Cloud.

快速回复 返回顶部 返回列表