http请求
发送http请求,通过命令行或者代码方法
> https://curlconverter.com
cURL
1 2 3
| curl -H "Content-Type:text/html" www.google.com # head curl www.google.com?cmd="ls -al" # get curl --data "param1=value1¶m2=value2" www.google.com # post
|
javascript fetch
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18
| fetch('http://www.google.com', { headers: { 'Content-Type': 'text/html' } });
fetch('http://www.google.com?cmd=ls -al');
fetch('http://www.google.com', { method: 'POST', headers: { 'Content-Type': 'application/x-www-form-urlencoded' }, body: 'param1' });
|
python request
通过python request库发送http请求
将cURL参数转为request代码
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
| import requests
headers = { 'content-type': 'text/html', }
response = requests.get('http://www.google.com', headers=headers) response = requests.post('http://www.google.com', headers=headers)
response = requests.get('http://www.google.com')
data = 'param1' response = requests.post('http://www.google.com', headers=headers, data=data)
|
chrome
get: 直接在输入框内输入请求即可
post: F12打开console用javascript