当前位置 : 主页 > 编程语言 > python >

python requests get传参

来源:互联网 收集:自由互联 发布时间:2021-06-25
GET传参方式一: import requestsurl = ‘ http://www.baidu.com/s?page=2 ‘ # 使用?携带参数r = requests. get (url)print(r.url) GET传参方式二: import requestsurl = ‘ http://www.baidu.com/s ‘ data = { ‘ page ‘ : ‘

GET传参方式一:

import requests

url = http://www.baidu.com/s?page=2  # 使用?携带参数
r = requests.get(url)
print(r.url)

GET传参方式二:

import requests
url = http://www.baidu.com/s  
data= {page: 2}  #将携带的参数传给params
r = requests.get(url, params=data)
print(r.url)
网友评论