Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit df7b37d

Browse files
committed
获取logo
1 parent d5710dc commit df7b37d

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

websites/code/studygolang/src/service/project.go

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -292,6 +292,11 @@ func ParseOneProject(projectUrl string) error {
292292
return errors.New("url" + projectUrl + "has exists!")
293293
}
294294

295+
logoSelection := doc.Find(".Project .PN img")
296+
if logoSelection.AttrOr("title", "") != "" {
297+
project.Logo = logoSelection.AttrOr("src", "")
298+
}
299+
295300
// 获取项目相关链接
296301
doc.Find("#Body .urls li").Each(func(i int, liSelection *goquery.Selection) {
297302
aSelection := liSelection.Find("a")
@@ -343,8 +348,6 @@ func ParseOneProject(projectUrl string) error {
343348
project.Author = "网友"
344349
}
345350

346-
// TODO: logo
347-
348351
if project.Doc == "" {
349352
// TODO:暂时认为一定是 Go 语言
350353
project.Doc = "https://godoc.org/" + project.Src[8:]

0 commit comments

Comments
 (0)