diff --git a/Readme b/Readme index 73123a3..ea73485 100644 --- a/Readme +++ b/Readme @@ -1,3 +1,2 @@ -今天遇到的问题过于多了 -、 -vpn感觉十分需要,可眼下并没有合适的 +1.今天遇到的问题过于多了,vpn感觉十分需要,可眼下并没有合适的 +2。正则表达式是真的坑,我透 \ No newline at end of file diff --git a/main.go b/main.go index ac5c938..d9c62d5 100644 --- a/main.go +++ b/main.go @@ -4,6 +4,7 @@ import ( "fmt" "io/ioutil" "net/http" + "regexp" ) func main() { @@ -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) { + //哲学 + //re:=regexp.MustCompile(`([^]+)`) + re := regexp.MustCompile(`([^"]+)`) //外边的小点 ` 并非是引号,我靠,花了好长时间 + matches := re.FindAllSubmatch(content, -1) + + for _, m := range matches { + fmt.Printf("url:%s\n", "https://book.douban.com"+string(m[1])) + + } + }