<!DOCTYPE html>
<html style="height: 100%">
<head>
<meta charset="utf-8" />
</head>
<body style="height: 100%; margin: 0">
<button onclick="search()">点击</button>
<div id="container" style="height: 100%"></div>
<script src="https://cdn.bootcdn.net/ajax/libs/axios/0.26.1/axios.min.js"></script>
<script
type="text/javascript"
src="https://cdn.jsdelivr.net/npm/echarts@5.3.2/dist/echarts.min.js"
></script>
<script type="text/javascript">
function search() {
axios
.get("./authorInfomation.json")
.then((res) => {
console.log(res);
var dom = document.getElementById("container");
var myChart = echarts.init(dom);
var app = {};
var option;
option = {
title: {
text: "csdn粉丝账户数据变化",
},
tooltip: {
trigger: "axis",
axisPointer: {
type: "shadow",
},
},
legend: {},
grid: {
left: "3%",
right: "4%",
bottom: "3%",
containLabel: true,
},
xAxis: {
type: "value",
boundaryGap: [0, 0.01],
},
yAxis: {
type: "category",
data: ["访问量", "粉丝数", "排名", "关注"],
},
series: [
{
name: "作者数据",
type: "bar",
data: [parseInt(res.data.fangwenCount), 815, 1467, 192],
},
],
};
if (option && typeof option === "object") {
myChart.setOption(option);
}
})
.catch((err) => {
console.log(err);
});
}
</script>
</body>
</html>
import requests
from bs4 import BeautifulSoup
import json
url = "https://blog.csdn.net/liulang68?spm=1011.2415.3001.5343"
headers = {
'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/80.0.3987.106 Safari/537.36'}
res = requests.get(url, headers=headers)
content = res.text
soup = BeautifulSoup(content, "lxml")
allCount = soup.select(".user-profile-statistics-num")
fangwenCount = allCount[0].string
fensiNum = allCount[1].string
paiming = allCount[2].string
guanzhu = allCount[3].string
authorInfomation = {}
authorInfomation["fangwenCount"]=fangwenCount
authorInfomation["fensiNum"]=fensiNum
authorInfomation["paiming"]=paiming
authorInfomation["guanzhu"]=guanzhu
print(authorInfomation)
json.dump(authorInfomation,open('authorInfomation.json','w'))