Skip to content

能否新增一个字段,统计指定页面的访问量? #886

Answered by qwqcode
white0dew asked this question in Q&A
Discussion options

You must be logged in to vote

你好,一般可以参考 https://artalk.js.org/guide/frontend/pv.html 查询访问量。

如果你想一次性获取多个页面的访问量 JSON 格式数据,可以通过直接请求 API 的方式获取,可以参考 OpenAPI 文档:https://artalk.js.org/http-api#tag/Statistic/operation/GetStats

示例:

GET https://artalk.qwqaq.com/api/v2/stats/page_pv?page_keys=a,b,c&site_name=ArtalkDocs

{"data":{"a":0,"b":0,"c":0}}
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>获取页面访问量示例</title>
</head>
<body>
    <h1>页面访问量统计</h1>
    <div id="stats"></div>

    <script>
        // 构建请求
        var pageKeys = ["a", "b", "c"]; // 要获取访问量的页面关键字列表
        var siteName = "ArtalkDocs"; // 站点名称
        var apiUrl = 

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@imysl0
Comment options

Answer selected by qwqcode
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
3 participants
Converted from issue

This discussion was converted from issue #881 on May 26, 2024 10:06.