可以插入Markdown文件或HTML网页的计数器
将下方代码的 name=
后替换为自己的标识符,再插入到网页中即可。
-
Markdown (推荐)
![Counter](https://counter.jerryz.com.cn/counter?name=counter)
-
HTML
<img src="https://counter.jerryz.com.cn/counter?name=counter" alt="Counter">
代码块前后也可以插入文字,例如:
-
是否将当前显示计入计数器
-
字体大小
![Counter](https://counter.jerryz.com.cn/counter?name=counter&font=20)
-
深色模式(显示白色字体)
![Counter](https://counter.jerryz.com.cn/counter?name=counter&dark=1)
-
自定义颜色
color后面的值为16进制颜色代码(不含
#
)或rgb(a)颜色代码(不含空格)![Counter](https://counter.jerryz.com.cn/counter?name=counter&color=279cff) ![Counter](https://counter.jerryz.com.cn/counter?name=counter&color=rgb(136,136,255)) ![Counter](https://counter.jerryz.com.cn/counter?name=counter&color=rgba(0,0,0,0.5))
以下是使用不同编程语言发送 API 请求的示例代码:
- Python:
import requests
url = "https://counter.jerryz.com.cn/api/counter"
name = "your_variable_here"
data = {"name": name}
response = requests.post(url, json=data)
times = response.json()["times"]
print(times)
- JavaScript:
const fetch = require('node-fetch');
const url = "https://counter.jerryz.com.cn/api/counter";
const name = "your_variable_here";
const data = { name };
fetch(url, {
method: 'POST',
body: JSON.stringify(data),
headers: { 'Content-Type': 'application/json' },
})
.then(response => response.json())
.then(data => {
const times = data.times;
console.log(times);
});
- Java:
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.net.HttpURLConnection;
import java.net.URL;
public class APIClient {
public static void main(String[] args) {
String url = "https://counter.jerryz.com.cn/api/counter";
String name = "your_variable_here";
String data = "{\"name\": \"" + name + "\"}";
try {
URL apiUrl = new URL(url);
HttpURLConnection connection = (HttpURLConnection) apiUrl.openConnection();
connection.setRequestMethod("POST");
connection.setRequestProperty("Content-Type", "application/json");
connection.setDoOutput(true);
connection.getOutputStream().write(data.getBytes());
BufferedReader reader = new BufferedReader(new InputStreamReader(connection.getInputStream()));
StringBuilder response = new StringBuilder();
String line;
while ((line = reader.readLine()) != null) {
response.append(line);
}
reader.close();
String jsonResponse = response.toString();
// Parse the JSON response and extract the "times" value
// ...
System.out.println(times);
} catch (Exception e) {
e.printStackTrace();
}
}
}
- PHP:
<?php
$url = "https://counter.jerryz.com.cn/api/counter";
$name = "your_variable_here";
$data = array("name" => $name);
$options = array(
'http' => array(
'header' => "Content-type: application/json",
'method' => 'POST',
'content' => json_encode($data),
),
);
$context = stream_context_create($options);
$response = file_get_contents($url, false, $context);
$responseData = json_decode($response, true);
$times = $responseData["times"];
echo $times;
?>
- 微信小程序:
wx.request({
url: 'https://counter.jerryz.com.cn/api/counter',
method: 'POST',
data: {
name: 'your_variable_here'
},
header: {
'Content-Type': 'application/json'
},
success: function (res) {
const times = res.data.times;
console.log(times);
},
fail: function (error) {
console.log(error);
}
});
在这些示例中,将 your_variable_here
替换为你实际想要发送的变量值。然后运行相应的程序以发送POST请求。如果要将当前请求计入计数器,url
使用 https://counter.jerryz.com.cn/api/counter
。如果不将当前请求计入计数器,url
使用 https://counter.jerryz.com.cn/api/view