实现description获取
This commit is contained in:
parent
a38f60978d
commit
4e50fa04b3
|
|
@ -0,0 +1,24 @@
|
|||
**/.classpath
|
||||
**/.dockerignore
|
||||
**/.env
|
||||
**/.git
|
||||
**/.gitignore
|
||||
**/.project
|
||||
**/.settings
|
||||
**/.toolstarget
|
||||
**/.vs
|
||||
**/.vscode
|
||||
**/*.*proj.user
|
||||
**/*.dbmdl
|
||||
**/*.jfm
|
||||
**/bin
|
||||
**/charts
|
||||
**/docker-compose*
|
||||
**/compose*
|
||||
**/Dockerfile*
|
||||
**/node_modules
|
||||
**/npm-debug.log
|
||||
**/obj
|
||||
**/secrets.dev.yaml
|
||||
**/values.dev.yaml
|
||||
README.md
|
||||
|
|
@ -9,7 +9,7 @@
|
|||
"type": "go",
|
||||
"request": "launch",
|
||||
"mode": "auto",
|
||||
"program": "/Users/suguo/project/search"
|
||||
"program": "/home/suguo/project/search"
|
||||
}
|
||||
]
|
||||
}
|
||||
|
|
@ -0,0 +1,15 @@
|
|||
#build stage
|
||||
FROM golang:alpine AS builder
|
||||
RUN apk add --no-cache git
|
||||
WORKDIR /go/src/app
|
||||
COPY . .
|
||||
RUN go get -d -v ./...
|
||||
RUN go build -o /go/bin/app -v ./...
|
||||
|
||||
#final stage
|
||||
FROM alpine:latest
|
||||
RUN apk --no-cache add ca-certificates
|
||||
COPY --from=builder /go/bin/app /app
|
||||
ENTRYPOINT /app
|
||||
LABEL Name=search Version=0.0.1
|
||||
EXPOSE 3000
|
||||
|
|
@ -0,0 +1,10 @@
|
|||
version: '3.4'
|
||||
|
||||
services:
|
||||
search:
|
||||
image: search
|
||||
build:
|
||||
context: .
|
||||
dockerfile: ./Dockerfile
|
||||
ports:
|
||||
- 3000:3000
|
||||
|
|
@ -0,0 +1,10 @@
|
|||
version: '3.4'
|
||||
|
||||
services:
|
||||
search:
|
||||
image: search
|
||||
build:
|
||||
context: .
|
||||
dockerfile: ./Dockerfile
|
||||
ports:
|
||||
- 3000:3000
|
||||
2
go.mod
2
go.mod
|
|
@ -3,6 +3,7 @@ module myschools.me/suguo/search
|
|||
go 1.19
|
||||
|
||||
require (
|
||||
github.com/PuerkitoBio/goquery v1.8.0
|
||||
github.com/google/uuid v1.3.0
|
||||
golang.org/x/net v0.0.0-20221014081412-f15817d10f9b
|
||||
gorm.io/driver/mysql v1.4.1
|
||||
|
|
@ -11,7 +12,6 @@ require (
|
|||
)
|
||||
|
||||
require (
|
||||
github.com/PuerkitoBio/goquery v1.8.0 // indirect
|
||||
github.com/andybalholm/cascadia v1.3.1 // indirect
|
||||
github.com/go-sql-driver/mysql v1.6.0 // indirect
|
||||
github.com/jinzhu/inflection v1.0.0 // indirect
|
||||
|
|
|
|||
|
|
@ -6,6 +6,4 @@ type Domain struct {
|
|||
Root string `gorm:"type:varchar(10);primarykey"`
|
||||
CreatedAt time.Time
|
||||
UpdatedAt time.Time `gorm:"index"`
|
||||
Success uint64
|
||||
Failure uint64
|
||||
}
|
||||
|
|
|
|||
|
|
@ -41,12 +41,14 @@ func siteAccess(url *string) {
|
|||
}
|
||||
|
||||
title := doc.Find("title").Text()
|
||||
r, _ := doc.Find("head").Html()
|
||||
fmt.Println(r)
|
||||
description := ""
|
||||
if title != "" && description != "" {
|
||||
//goto search
|
||||
fmt.Println(title, description)
|
||||
doc.Find("meta").Each(func(i int, s *goquery.Selection) {
|
||||
if name, _ := s.Attr("name"); name == "description" {
|
||||
description, _ = s.Attr("content")
|
||||
}
|
||||
})
|
||||
if title == "" || description == "" {
|
||||
return
|
||||
}
|
||||
|
||||
urls := urlAnalysis(resp.Body)
|
||||
|
|
|
|||
Loading…
Reference in New Issue