问题requests.exceptions.InvalidHeader: Invalid return character or leading space in header: user-agent解决方案
运行时提示:
requests.exceptions.InvalidHeader: Invalid return character or leading space in header: user-agent
主要原因是headers中的值开头不能是空格
正确:'user-agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/98.0.4758.102 Safari/537.36'
错误:'user-agent': ' Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/98.0.4758.102 Safari/537.36'