You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
23 lines
490 B
23 lines
490 B
package kuaishou
|
|
|
|
import "regexp"
|
|
|
|
func (app *App) ExtractImageLink(content string) []string {
|
|
|
|
//解析正则表达式,如果成功返回解释器
|
|
reg := regexp.MustCompile(`\{"path":"(.*?)","width":\d+,"height":\d*}`)
|
|
|
|
//根据规则提取关键信息
|
|
result := reg.FindAllStringSubmatch(content, -1)
|
|
var imageLinks []string
|
|
|
|
if len(result) > 0 {
|
|
for _, link := range result {
|
|
imageLinks = append(imageLinks, "https://tx2.a.yximgs.com"+link[1])
|
|
}
|
|
|
|
}
|
|
|
|
return imageLinks
|
|
}
|