python request获取真实302地址
2023-09-27 14:27:48 时间
HEADERS = {
'accept-encoding': 'gzip, deflate, br',
'accept-language': 'zh-CN,zh;q=0.9',
'pragma': 'no-cache',
'cache-control': 'no-cache',
'upgrade-insecure-requests': '1',
'user-agent': "Mozilla/5.0 (iPhone; CPU iPhone OS 11_0 like Mac OS X) AppleWebKit/604.1.38 (KHTML, like Gecko) Version/11.0 Mobile/15A372 Safari/604.1",
}
def get_real_address(url):
if url.find('v.douyin.com') < 0:
return url
res = requests.get(url, headers=HEADERS, allow_redirects=False)
return res.headers['Location'] if res.status_code == 302 else None
相关文章
- 如何通过Python扩展库的安装信息快速找到某扩展库的官方资料(文档、官网、github地址等)?
- [攻防世界]-WEB高手进阶区-Web_python_block_chain
- python 数据类型详解(转)
- 30岁,我为什么转行python,是这辈子最成功的一件事......
- 学习Python语言有什么用?
- 手把手讲解超详细python入门游戏项目‘打外星飞船’(四)
- Docker+Selenium Grid+Python搭建分布式测试环境
- python第四十七课——类属性和函数属性
- 【图像处理】——图像增强Python实现直方图均衡化
- Python每日一学 11——流程跳转语句
- Python实现APP UI自动化以及OpenCV图像识别元素
- python实现pdf转换成图片
- AttributeError: module 'torch._C' has no attribute '_cuda_setDevice'(在python命令后面加上 --gpu_ids -1)