ddxiami

 找回密码
 立即注册
搜索
热搜: 活动 交友 discuz
查看: 2612|回复: 2

基础语法10--web请求(get和post)

[复制链接]
发表于 2020-4-17 22:28:52 | 显示全部楼层 |阅读模式
#安装组件
pip3 install requests


#参考网址
https://www.cnblogs.com/lsdb/p/9052257.html
回复

使用道具 举报

 楼主| 发表于 2020-4-17 22:29:27 | 显示全部楼层
#get请求
====================
#!/usr/bin/python3

import requests
response = requests.get(url='https://www.baidu.com/',params={'key1':'value1','key2':'value2'})
print(response.text)
回复 支持 反对

使用道具 举报

 楼主| 发表于 2020-4-17 22:40:57 | 显示全部楼层
#post请求
====================
#!/usr/bin/python3

import requests

response = requests.post(url='https://xx.xxx.net/xxx/User/getAvatar',data={'token':'xxxx','token_type':'base','rand_num':'123456'},headers={'Content-Type':'application/x-www-form-urlencoded'})
print(response)
回复 支持 反对

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

小黑屋|手机版|Archiver|技术文档库 ( 闽ICP备15017263号-2 )|网站地图

GMT+8, 2025-5-18 17:31 , Processed in 0.036032 second(s), 16 queries .

Powered by Discuz! X3.4

Copyright © 2001-2020, Tencent Cloud.

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