【腾讯云 TDSQL-C Serverless产品体验】抓取processon热门模版的标题生成词云
serverless服务是腾讯云自研的新一代云原生关系型数据库TDSQ L-C的无服务器架构版,是全Serverless架构的云原生数据库
前言
体验了一下腾讯云刚出的TDSQL-C Serverless,使用它存储数据比较方便,能根据负载动态扩容,现在我们正好用来爬下数据分析一下。
数据源
processOn是比较常用的画图平台,它的模版也是比较丰富,但是基本上都要钱。。。
现在我们爬一下数据,看下这些推荐的模版标题的构成,即什么样的词汇比较容易被推荐,还有它的价格分布是怎样的
项目目录
config存储配置文件,dao负责链接数据库,logic下面就是具体的逻辑,包括爬虫、分析、词云分词。
爬虫
具体爬虫代码如下,这里才有异步存储,也正好测试下数据库的性能如何
import (
"fmt"
"github.com/anaskhan96/soup"
"github.com/spf13/cast"
"strings"
"sync"
"td_test/logic/wordcloud"
)
func Crawl(url string) error {
res, err := soup.Get(url)
if err != nil {
return err
}
var wg sync.WaitGroup
doc := soup.HTMLParse(res)
// 模版列表
tempList := doc.FindAll("div", "class", "list-item-content")
for _, item := range tempList {
// 模版详情数据
detail := item.Find("div", "class", "temp-item-detai