Skip to content

Commit

Permalink
继续加油
Browse files Browse the repository at this point in the history
  • Loading branch information
QuinnDK committed Apr 27, 2020
1 parent 1802201 commit 6cf0603
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 4 deletions.
5 changes: 2 additions & 3 deletions Readme
Original file line number Diff line number Diff line change
@@ -1,3 +1,2 @@
今天遇到的问题过于多了
vpn感觉十分需要,可眼下并没有合适的
1.今天遇到的问题过于多了,vpn感觉十分需要,可眼下并没有合适的
2。正则表达式是真的坑,我透
23 changes: 22 additions & 1 deletion main.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"fmt"
"io/ioutil"
"net/http"
"regexp"
)

func main() {
Expand Down Expand Up @@ -33,5 +34,25 @@ func main() {
panic(err)
}

fmt.Printf("%s", result)
//fmt.Printf("%s", result)
ParseContent(result)

//正则表达式
// str:="asdajidasfksaiaioaskfivsvs"
// re:=regexp.MustCompile(".*ksai")
// rest:=re.FindString(str)
// fmt.Println(rest)
}

func ParseContent(content []byte) {
//<a href="/tag/哲学" class="tag">哲学</a>
//re:=regexp.MustCompile(`<a href="([^"]+)">([^</a>]+)</a>`)
re := regexp.MustCompile(`<a href="([^"]+)" class="tag">([^"]+)</a>`) //外边的小点 ` 并非是引号,我靠,花了好长时间
matches := re.FindAllSubmatch(content, -1)

for _, m := range matches {
fmt.Printf("url:%s\n", "https://book.douban.com"+string(m[1]))

}

}

0 comments on commit 6cf0603

Please sign in to comment.